How to append text in every line of a file except for the first line How to append text in every line of a file except for the first line unix unix

How to append text in every line of a file except for the first line


How about:

sed -e '2,$ s/$/|Paris/' < abc.txt

And including the header:

sed -e '1 s/$/|Place/' -e '2,$ s/$/|Paris/' < abc.txt

For the last line, you must have an extra blank line in the file. So, delete all lines containing nothing but zero or more spaces:

sed -e '/^ *$/ d' -e '1 s/$/|Place/' -e '2,$ s/$/|Paris/' < abc.txt


This might work for you (GNU sed):

sed '1s/$/|Place/;/./!b;1!s/$/|Paris/' file

This appends |Place to the first line, ignores empty lines and all other lines appends |Paris.