Append text to end of line on all lines

Hi,

I've spent some time researching for this but can't seem to find a solution. I have a file like this

1234|Test|20101111|18:00|19:00

There will be multiple lines in the file with the same kind of format. For every line I need to make it this

1234|Test|20101111|18:00|19:00||create schedule.

I tried a simple sed like

sed -e 's/$/create schedule/g'

but that appends the text at the beginning of the line.

Any help would be greatly appreciated.

Thanks,
Giles

awk '{$0=$0"||create schedule"}1' file

That sed should work.

sed -e 's/$/||create schedule/g' oldfile newfile

Perhaps your data file is not in correct unix text file format. Did it come from a Microsoft platform?

This should work:

sed 's/$/||create schedule/' infile

If you get it at the beginning of the line, you need to convert your file from dos to unix format first.

You could:-

cat ${file}|while read line
do
   echo "${line}||create schedule"
done>file.new

It's a bit slow for larger files though because of all the calls it makes. How about:-

echo ":%s /$/||create schedule\n:wq"|vi file

Your sed looks right, but it may be a quotation issue that makes the shell assume that the $ is a signal that there is a variable next, but when there isn't on, it assumes start of line. Perhaps you need to escape the $ with

sed -e 's/\$/create schedule/g'

but I would initially expect that to look for the literal character $ rather than the end of line.

You could perhaps use awk something like:-

awk '{ print $* "||create schedule"}' file > file.new

I hope that this gives some help.

Robin
Liverpool/Blackburn
UK

Thanks for the replies chaps,

Pesky ^M characters, totally forgot to check for that. Doing a dos2unix first works.

Cheers,
Giles