Computing.Net > Forums > Unix > replacing the path definition

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.

replacing the path definition

Reply to Message Icon

Name: kparthiban
Date: August 17, 2005 at 08:02:40 Pacific
OS: unix
CPU/Ram: 255
Comment:


Please help me in writing a script
I have to write a script for replacing a
line in a file

For Eg.
1)The file name is testfile
2) The testfile contains about 100 lines
3) I want to replace the 10th line and 20th
line in the file

4) The line is in the format as follows

10th line--setenv WORK_DIR /opt/informix/
this should be replaced with the following
new line---setenv WORK_DIR /home/informix/

the 20 th line as like same format

so how to write a script to replace the
multiple lines in the file

Thanks in advance

parthiban



Sponsored Link
Ads by Google

Response Number 1
Name: Luke Chi
Date: August 17, 2005 at 11:27:18 Pacific
Reply:

awk ' { if ( NR == 10 || NR == 20 ) sub(/^setenv WORK_DIR \/opt\/informix\/$/, "setenv WORK_DIR /home/informix/"); print } ' input.txt

Luke Chi


0

Response Number 2
Name: kparthiban
Date: August 18, 2005 at 03:20:01 Pacific
Reply:

thanks for your help

parthiban


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


install unix C Shell Script Help



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: replacing the path definition

Redirect path in csh script www.computing.net/answers/unix/redirect-path-in-csh-script/8329.html

Is the Mobo about to go www.computing.net/answers/unix/is-the-mobo-about-to-go/1835.html

One more Q. (find and replace) www.computing.net/answers/unix/one-more-q-find-and-replace/5826.html