I have a requirement to print two different words in alternative white spaces in the file.
For example,
ABCD EFGH IGKL MNOP
The above scenario, I want print ab and /ab alternatively like below:
ab ABCD /ab ab EFGH /ab ab IGKL /ab ab MNOP /ab
*I want this one by one in a line by line format(Not horizontal format).*I know sed 's|^[[:blank:]]*$|</ab>|'
this command is almost near to my case. But I don’t know how to apply this. Please, someone, help me.
Advertisement
Answer
If you are ok with awk
then following may help you here.
awk -v start="ab" -v end="/ab" '{print start ORS $0 ORS end}' Input_file
In case you need to save output into Input_file itself then append > temp_file && mv temp_file Input_file
in above code too.