Computing.Net > Forums > Unix > sed help

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 help

Reply to Message Icon

Name: gera
Date: September 5, 2006 at 16:18:35 Pacific
OS: XP
CPU/Ram: P4
Comment:


I need to comment out one line from myfile

My file: foo.txt

test_resume_one
pass_resume_two
fail_resume_three

I want to put # at the start of pass_resume_two
so that my foo.txt look

test_resume_one
#pass_resume_two
fail_resume_three

Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: don2006
Date: September 5, 2006 at 16:34:52 Pacific
Reply:

What's wrong with using vi?


0

Response Number 2
Name: gera
Date: September 5, 2006 at 17:52:56 Pacific
Reply:


Nothing is wrong with using VI . I have
"pass_resume_two" at the start of a line
in multiple lines inside foot.txt. That is why
I am trying to use sed.


0

Response Number 3
Name: nails
Date: September 5, 2006 at 20:02:30 Pacific
Reply:


sed 's/^pass_resume_two/#pass_resume_two/g' data.file


0

Response Number 4
Name: nails
Date: September 5, 2006 at 20:43:14 Pacific
Reply:

Come to think of it, you can still use vi:

vi data.file <<MSG
:g/^pass_resume_two/s//#pass_resume_two/g
:wq
MSG


0

Response Number 5
Name: lchi2000g
Date: September 13, 2006 at 18:59:01 Pacific
Reply:

Based on nails solutions:

1. sed 's/^pass_resume_two/#&/g' data.file

2. vi data.file <<MSG > /dev/null 2>&1
:g/^pass_resume_two/s//#&/g
:wq
MSG

Luke Chi


0

Related Posts

See More



Response Number 6
Name: lchi2000g
Date: September 13, 2006 at 19:03:12 Pacific
Reply:

3. vi data.file <<MSG > /dev/null 2>&1
:1,\$s/^pass_resume_two/#&/g
:wq
MSG


Luke Chi


0

Sponsored Link
Ads by Google
Reply to Message Icon

compression help Crontab issue



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: sed help

Sed Help [/] www.computing.net/answers/unix/sed-help-/6762.html

sed help with variable length file www.computing.net/answers/unix/sed-help-with-variable-length-file/5632.html

sed help www.computing.net/answers/unix/sed-help/6080.html