Computing.Net > Forums > Unix > replace a newline with string

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.

replace a newline with string

Reply to Message Icon

Name: raxit
Date: February 28, 2003 at 07:55:27 Pacific
OS: hpux
CPU/Ram: 133
Comment:

hi,
i need to add a string like /java at the end of each line in a file. i tried it using commands like tr '\012' '/java\012' but i think
tr command only replaces a character.
tried it using sed command ..but that also doesnt work.
please help.
thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: neel
Date: February 28, 2003 at 08:19:51 Pacific
Reply:

can you try
sed 's/$/java$/g' File.EXT > file
I think it will work.


0

Response Number 2
Name: anukta_c
Date: February 28, 2003 at 08:21:58 Pacific
Reply:

Try
sed 's/$/\/java/g' yourfilename > newfile
-Anukta


0

Response Number 3
Name: neel
Date: February 28, 2003 at 08:24:18 Pacific
Reply:

Yeah .. missed the \/ part..
hey Ankuta dont you think we need to put java$ rather than java ?
~ Neel !!


0

Response Number 4
Name: anukta_c
Date: February 28, 2003 at 08:30:59 Pacific
Reply:

java$ will obviously work...but simply /java substitution will work as well. Though I cannot explain why. I will leave that to the Gurus of this forum.
-Anukta


0

Response Number 5
Name: anukta_c
Date: February 28, 2003 at 08:33:18 Pacific
Reply:


OOPS....sorry java$ substitution will not work...it will actually do a literal substitution with "java$".

-Anukta


0

Related Posts

See More



Response Number 6
Name: raxit
Date: February 28, 2003 at 08:39:05 Pacific
Reply:

hey ,
anukta and neel..my problem is solved
thanks for your help.


0

Sponsored Link
Ads by Google
Reply to Message Icon






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: replace a newline with string

Replacing a pattern with a variable www.computing.net/answers/unix/replacing-a-pattern-with-a-variable/7040.html

replacing a character with a tab www.computing.net/answers/unix/replacing-a-character-with-a-tab/4966.html

How to replace a string w/ var www.computing.net/answers/unix/how-to-replace-a-string-w-var/7439.html