I know that awk can display diffrent parts of a file, how do I edit specific sections?
sed is going to be your friend here.
A specific example of your problem could help us give a more specific example of a solution.
To append lines to a file you can use echo and your shell's pipe redirection:
echo "hello" >> my_file.txt
sed . . . 100%
If you need help, ask !
I have found my answer to my problem, and maneuver around SED. So in the begenning I saw that there was a java course on udemy and I thought that now is a good a time as any to start learning (their have also been some things I want to achive with android and this appers to be the way) So I go to an IDE which I have used in the past that looks good and isn't Eclipse which is Intelij. So when I download the archive and unzip it not in the command line like a should have done I unchecked the box for some reason which maintains directory structure, so to put it bluntly, my home folder was a mess. Now My problem started in the clean up. When in something like a graphical file manager, you can either view it in a list or in a grid, and only in the grid can you select more than one file at a time for deletion, so that is off the table. So with that I saw this as a prime opertunity to learn more about bash so I thought that the best course of action was to delete all the most recent files. With that in mind the first command I thought of was ls -la
, How ever the file output gave me a bunch of information I didn't need, and it didn't organize by time, how ever I just put in all the data that didn't matter in under the wild card, then just put in the date where it should be and grep gave me a list which I put into a file. This is where my need for automated text editing comes into play. So with the file output I needed something which rm could use and not have all the excess, and the lines had the same distance in characters to the file name, so I needed to use some type of automated text editng per line (Which there was about 3000) to just make sure that I didn't spend all day manually deleting lines of text. Now here's the part where I figure out the easiest way to do things. So it all goes back to ls. I feel that it is stupid to go on this route and I go back to the man page of ls, when much to my shagrin, I find that ls -t
does what I need, so in the end I just used this command to do my job ls -t > DeleteStuff.txt && nano DeleteStuff.txt && cat DeleteStuff.txt | xargs rm -rf
It's potentially dangerous to your .config directory, but you could also use find
to delete files created within 15 minutes or so. The problem there is it can be quite dangerous.
Glad you found a solution!
find . -cmin +<time>
find . -cmin -<time>
find . -cmin <time>
+100
I edited the text file to not include the directories I wanted to keep.