I wish to list the files of a few folders, in reverse alphabetical order, and then aggregate that data into a single file (AllDirectoriesFileInfo.txt). I've already figured out the sorting; now it is merely collating the info that is stumping me. Here is what I have so far:
ls -r /home/tony/Desktop/jpgfolder > AllDirectoriesFileInfo.txt
ls -r /home/tony/Desktop/giffolder > AllDirectoriesFileInfo.txt
ls -r /home/tony/Desktop/docxfolder > AllDirectoriesFileInfo.txt
ls -r /home/tony/Desktop/dregsfolder > AllDirectoriesFileInfo.txt
However, upon inspection of AllDirectoriesFileInfo.txt, only the information from dregsfolder is present, leading me to conclude that the previous data has been overwritten with each command.
So, I am aware that sed can add/insert text.
Initially I was leaning towards using a;
The syntax is as simple, simply designate the line after which a new line is to be inserted by using its corresponding number or a pattern.
However for me, specifying a line number is problematic. Say I specify line 50, will there be a massive desert of white space? Or say a larger file is utilised, then does the information become garbled?
I am aware that with the i command (insert) the user is able to specify the point at which new text is inserted.
My thinking, and pseudocode is as follows:
All information of folder 1 stored here
**END of folder 1 info**
All information of folder 2 stored here
And then from there, use SED to insert the next file after END of folder 1 info
Would this work? Or am I barking at the moon here?