I have a text file (1.txt) as follows:
word1 word2 word3
I use sed to add strings to the beginning and end of every line as follows:
sed 's/^/blahblah1 /g' 1.txt > 2.txt sed 's/$/ blahblah2/g' 2.txt > 3.txt
blahblah1 word1 blahblah2 blahblah1 word2 blahblah2 blahblah1 word3 blahblah2
This works fine, but I want to do something further.
I want to copy the strings in the middle of each line (word1, word2, etc.) to the end of every line as follows:
blahblah1 word1 blahblah2 word1 blahblah1 word2 blahblah2 word2 blahblah1 word3 blahblah2 word3
PLEASE NOTE that blahblah1 and blahblah2 are just representing bash commands and other string text AND are the same at the beginning and end of every line as the sed commands illustrate – the strings between them are DIFFERENT – and the strings are not actually "blahblah1" and "blahblah2".
Basically, I'm taking a text file containing a list of strings and want to create a bash script containing a list of commands to grab lines of code containing a string and dump them to files with a file name containing that string – hence the structure of each line.