Computing.Net > Forums > Unix > Replace entire line

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 entire line

Reply to Message Icon

Name: pratheep
Date: November 12, 2008 at 03:38:01 Pacific
OS: Xp
CPU/Ram: 2 gb
Product: Microsoft
Comment:

I need to replace an entire line which has a keyword export. before export there may be # or anything...

for eg,

#export hhhh
export bbbb

in file sam.sc

i need to change that two lines to

export hhhh
#export bbbb

Please someone help me...



Sponsored Link
Ads by Google

Response Number 1
Name: lankrypt0
Date: November 14, 2008 at 11:13:04 Pacific
Reply:

If you are looking to swap the # and non #, try this:
sed -e "s/^export/:export/g" -e "s/#export/export/g" -e "s/:export/#export/g" < tfile


0

Response Number 2
Name: pratheep
Date: November 16, 2008 at 19:50:31 Pacific
Reply:

That's working... now i need to execute my .profile from script... i gae the command , but its not executing... could you help me in this...?

this is the command i gave in the script...

cd /home/user/
. ./.profile


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: Replace entire line

how to replace a line in a file www.computing.net/answers/unix/how-to-replace-a-line-in-a-file/7214.html

Script for replacing multiple lines www.computing.net/answers/unix/script-for-replacing-multiple-lines/4145.html

Need help with a search and replace logi www.computing.net/answers/unix/need-help-with-a-search-and-replace-logi/3296.html