Computing.Net > Forums > Programming > Sed:Add text to end of line in file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Sed:Add text to end of line in file

Reply to Message Icon

Name: Deepesh
Date: February 21, 2007 at 22:59:55 Pacific
OS: HP-UX
CPU/Ram: 512MB
Product: HP-UX
Comment:

Hi,

Could you help me with a sed command to add a text in all the line in a particular file ?

Apart from sed is there any other command which could achieve this ?

Regards,
Deepesh




Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: February 22, 2007 at 07:03:21 Pacific
Reply:


#!/bin/ksh

# add to text to end of a file using sed
sed 's/$/Add Text to end"/g' myfile

# using awk
awk ' { print $0"Add Text to end" } ' myfile


0

Response Number 2
Name: Deepesh
Date: February 22, 2007 at 21:56:35 Pacific
Reply:

Hi,

Thanks a lot for your response !!
Actually command is adding the text at the start of all the line.

What is the option to append at end of the lines ?

Thanks a lot,
Deepesh


0

Response Number 3
Name: nails
Date: February 23, 2007 at 08:40:52 Pacific
Reply:

I'm not understanding:

>Actually command is adding the text at the start of all the line.

The two solutions I gave you do append the text to the end of the line. In the sed example, $ is a regular expression which identifieds the end of the line.

Please elaborate or better yet, post some code and tell us where you are having a problem.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Sed:Add text to end of line in file

How to remove end-of-line in a file www.computing.net/answers/programming/how-to-remove-endofline-in-a-file/10873.html

echo text to specific line in file www.computing.net/answers/programming/echo-text-to-specific-line-in-file/11965.html

Batch file to extract certain lines www.computing.net/answers/programming/batch-file-to-extract-certain-lines/17465.html