how to replace a line in a file
|
Original Message
|
Name: arun.s
Date: November 15, 2005 at 03:00:26 Pacific
Subject: how to replace a line in a fileOS: unixCPU/Ram: 255 |
Comment: my problem is i want to replace a line in a file e.g i want to replace the line DBUID= (some name) with DBUID=$user variable file name is sample.ksh DBUID=aruns010 please help me in solving this problem. i want to replace the entire line by using DBUID as the search parameter.i dont know the characters after DBUID=....? help me out as soon as possible thanks
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: nails
Date: November 15, 2005 at 13:12:00 Pacific
Subject: how to replace a line in a file |
Reply: (edit)It's kludgy, but if the line begins with DBUID, this [n]awk script replaces the entire line with variable $DBUID: #!/bin/ksh user=dave DBUID="DBUID=$user" # Solaris uses nawk, you might need awk nawk ' { if(/^DBUID/) $0=v1 print } ' v1="$DBUID" sample.ksh
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: nails
Date: November 15, 2005 at 22:15:04 Pacific
Subject: how to replace a line in a file |
Reply: (edit)William: I tried running your sed script above and I'm getting a garbled command error. I tried it on Solaris 7 and Red Hat Linux 7.1 Regards, Nails
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: nails
Date: November 16, 2005 at 07:10:25 Pacific
Subject: how to replace a line in a file |
Reply: (edit)Arun: I don't have another solution. What's wrong with the awk solution I gave you?
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: arun.s
Date: November 16, 2005 at 20:20:41 Pacific
Subject: how to replace a line in a file |
Reply: (edit)hi nails its ok man.. i got the solution for the problem. thanks for the help.. thanks Arun
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: