| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
replacing the path definition
|
Original Message
|
Name: kparthiban
Date: August 17, 2005 at 08:02:40 Pacific
Subject: replacing the path definition OS: unixCPU/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
Report Offensive Message For Removal
|
|
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
Report Offensive Follow Up For Removal
|

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
Results for: replacing the path definition
passing paramters with spaces Summary: Joe: I'm not an Oracle person, but sometimes the shell eats the double quotes. Have you tried something like: nohup sqlplus -s $UID_PWD @run_mail.sql $sender ""$receiver $subject $body"" where the la...
www.computing.net/answers/unix/passing-paramters-with-spaces/6406.html
Unix mail with attachment and a body Summary: I have to e-mail some files from unix to Netscape periodically. I have a shell script for this purpose. I can attach a file with the proper subject and mail it using mailx/mail. But if I do this I am ...
www.computing.net/answers/unix/unix-mail-with-attachment-and-a-body/2421.html
Is the Mobo about to go Summary: Guys, I know nothing about Unix, so I thought... I'll ask someone who does. My wife's work has a small server (don't ask whats in it yet cause I haven't looked) The server is running as a Unix box wit...
www.computing.net/answers/unix/is-the-mobo-about-to-go/1835.html