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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed replace with spaces in line 1

Status
Not open for further replies.

ksbrace

Programmer
May 13, 2000
501
US
hello, I am trying to use sed to replace lines in files but the line has spaces and seems to be giving me issues.
I want this line:
ALEPH_COPY 2

to become this line:
ALEPH_COPY 3

I have a conf file that fills in env variables and then I have a script that does the following:
Code:
echo "Updating Aleph start files..."
echo "START_AC: $START_AC"
echo "DEST_AC: $DEST_AC"
echo "$SED 's/'${START_AC}'/'${DEST_AC}'/g' $ALEPH_START > $ALEPH_START_TEMP"
$SED 's/'${START_AC}'/'${DEST_AC}'/g' $ALEPH_START > $ALEPH_START_TEMP

I am also echo'ing the variables as well as the command to try and figure out what is going wrong:

Updating Aleph start files...
START_AC: ALEPH_COPY 2
DEST_AC: ALEPH_COPY 3
/usr/bin/sed 's/'ALEPH_COPY 2'/'ALEPH_COPY 3'/g' /aleph/prod/itx/alephe/aleph_start > /aleph/prod/itx/alephe/aleph_start.tmp
sed: Function s/ALEPH_COPY cannot be parsed.


When I change the conf file to this:
START_AC=ALEPH_COPY
DEST_AC=TEST

everythign goes fine, so I'm being forced to think it has seomthign to do with the spaces.
output:

Updating Aleph start files...
START_AC: ALEPH_COPY
DEST_AC: TEST
/usr/bin/sed 's/'ALEPH_COPY'/'TEST'/g' /aleph/prod/itx/alephe/aleph_start > /aleph/prod/itx/alephe/aleph_start.tmp

Any help would be greatly appreciated. Thanks in advance.

 
Try this:

Code:
$SED "s/${START_AC}/${DEST_AC}/g" $ALEPH_START > $ALEPH_START_TEMP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top