Computing.Net > Forums > Linux > help with sed ( I think)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

help with sed ( I think)

Reply to Message Icon

Name: ojschubert
Date: March 2, 2005 at 18:30:44 Pacific
OS: Redhat 9.0
CPU/Ram: i686
Comment:

Hi,
I'm kind of a linux newbie so please forgive any stupid questions or commenets.

I'm trying to edit a text document using the sed command. I basically want to be able to go to a specific spot and change the data. The document looks similar to this:

row1: 39
row2: 49
row3: 85
etc....

Just as an example, I'd like to go and change whatever is at the end of row3 to another number. So after the edition the document will look like this.

row1: 39
row2: 49
row3: 99
etc....

I'd prefer to do this in userspace with the sed command but if anyone has a simplier way let me know.

The text may contain multiple instances of the same number other wise I could probably just do

sed -i 's/85$/99/' filename

That's about it. Any help is appreciated.


OJ



Sponsored Link
Ads by Google

Response Number 1
Name: totty (by allan_totty)
Date: March 3, 2005 at 01:49:26 Pacific
Reply:

Have a look on IBM's developer works site, theres a good sed tutorial.

http://www-130.ibm.com/developerworks/

you'll have to register but it's free.


0

Response Number 2
Name: David Perry
Date: March 3, 2005 at 04:26:25 Pacific
Reply:

sed -e "/row3/s/:.*$/: 99/" inputfile > outputfile


0

Response Number 3
Name: ojschubert
Date: March 3, 2005 at 08:12:50 Pacific
Reply:

Hello,

Thanks for the replies.

I tried the follwoing like you suggested and it didn't work.

sed -e "/row3/s/:.*$/: 99/" inputfile > outputfile

It gives me this error:

sed: -e expression #1, char 16: Unterminated `s' commnad


OJ


0

Response Number 4
Name: David Perry
Date: March 3, 2005 at 09:40:54 Pacific
Reply:

What version of sed are you using?

sed -V

the sample should work.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


dual boot linux and win X... Linux can use in internet...



Post Locked

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


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: help with sed ( I think)

need help with sed/awk www.computing.net/answers/linux/need-help-with-sedawk/29375.html

help with unix command www.computing.net/answers/linux/help-with-unix-command/24889.html

help with Apache www.computing.net/answers/linux/help-with-apache/8990.html