Computing.Net > Forums > Unix > Using sed to add characters

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.

Using sed to add characters

Reply to Message Icon

Name: Anukta C.
Date: September 19, 2002 at 06:43:52 Pacific
OS: HP-UX
CPU/Ram: 130
Comment:

Hi,
I have to add the characters "//#" to the beginning of each line in a file. My shell is the Korn shell.
I am trying to do
sed s/^///#/ abc > a
But this did not work. So i tried
sed s/^/\/\/#/ abc > a
But this did not work either. I even tried enclosing it with double-quotes.
Any ideas how to do this?
-Anukta



Sponsored Link
Ads by Google

Response Number 1
Name: jimbo
Date: September 19, 2002 at 06:52:51 Pacific
Reply:

Change your delimeters to something like this:

sed 's?^?//#?' file > outfile

-jim


0

Response Number 2
Name: Anukta C
Date: September 19, 2002 at 07:08:50 Pacific
Reply:

Worked like a dream !!
Thanks a lot.
-Anukta


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 Unix Forum Home


Sponsored links

Ads by Google


Results for: Using sed to add characters

How do I use sed to replace LF(SP) www.computing.net/answers/unix/how-do-i-use-sed-to-replace-lfsp-/7244.html

Using sed to update a single row www.computing.net/answers/unix/using-sed-to-update-a-single-row/7552.html

Extract text using sed www.computing.net/answers/unix/extract-text-using-sed/5169.html