Adding 2 lines to Every File in a Directory
Introduction Quickly wanted to write about a method I used to extract 2 lines from one of my posted and add it to all my other posts. clip=$(sed -n '5,6p' file-with-option.md) ls -1 | xargs -i sed -i "4a $clip" {} Quick explaination. We are saving the lines 5 and 6 from our desired file into $clip. Then we list all the files without fuzz, pipe them to xargs and set to run the commands individually, appending our $clip variable to line 4 ...