Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing string in a specific line

Status
Not open for further replies.

chibaru

Programmer
Aug 24, 2005
13
US
I'm trying to replace text in a specific line and can't get it to work. I'm fairly new with Unix scripting. I tried searching the forum but didn't find one that fit my needs.

I have a file of transactions and the first record of the file contains a header with a date. I would like to replace the date with another date. The header starts with a '1' in the first position.

I tried using sed but that didn't work....(please don't laugh):

sed -e '/^1/s/$hdrdte/$Curr_dte/g' $file

 

try it with double quotes:
Code:
sed -e "/^1/s/$hdrdte/$Curr_dte/g" $file >${file}.new
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
sed -e "/^1/s!$hdrdte!$Curr_dte!" $file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you both for such quick response!! They both worked great!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top