Add symbol to the end of every other line
Hello everyone,
I'm sure that this is extremely simple, but don't understand the sed command enough to do it myself. Basically, if I have a list such as that below, I want to add a ; symbol to the end of every other line: NOOB_1 abcdefghijklmn NOOB_2 abcdefggggghigglfkj NOOB_1245 abcddefiigohgggg So I want to alter the above to give the following: NOOB_1 abcdefghijklmn; NOOB_2 abcdefggggghigglfkj; NOOB_1245 abcddefiigohgggg; Thanks to anyone that can help. I have managed to add a symbol to the end of EVERY line, but not every OTHER line. |
Have a look at this:
Code:
gawk '{ if ( NR%2 != 1 ) { print $0";" } else { print } }' infile |
Code:
sed -i '0~2s/$/;/' file Code:
The following address types are supported: |
That's perfect. Thank you both. I'm getting the hang of sed now :)
|
All times are GMT -5. The time now is 09:41 AM. |