Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
The line of text that I am trying to use is -
sed 's/flag1/$cnumber' $header > $header
I have a document (header) with place holders flag1, flag2, flag3, etc. I want to replace the place holder with the value of $cnumber.
The error I get is "sed: 0602-404 function s/flag1/$cnumber cannot be parsed.
The file "header" looks like
{{Begin}}
{{Company flag1}}
{{Winsecid LAWSON_FAX}}
{{Contact flag2}}
{{Endcovertext}}
{{Fax flag3}}
Can somebody tell what I am doing wrong?

I must be doing something wrong. I tried enclosing the value in single and double quotes, double and single quotes, single quotes, and finally double quotes.
sed -e 's/flag1/"'$cnumber'"/' $header > $header.txt
None of it seems to work.

It works on my Solaris 9 box:
#!/bin/ksh
cnumber=myflag
sed -e 's/flag1/'"${cnumber}"'/' header > header.txt

Thank you for the help. I will check with operations for our AIX box. There has to be something a little different.

sed 's/flag1/$cnumber' $header > $header
The first problem is redirecting to the file you are reading from clobbers your input file.
Try this:
header=header
cnumber=10sed -e "s/flag1/"${cnumber}"/" $header > header1
Your header file before:
{{Begin}}
{{Company flag1}}
{{Winsecid LAWSON_FAX}}
{{Contact flag2}}
{{Endcovertext}}
{{Fax flag3}}
Your header file after:{{Begin}}
{{Company 10}}
{{Winsecid LAWSON_FAX}}
{{Contact flag2}}
{{Endcovertext}}
{{Fax flag3}}Tested on AIX

![]() |
Code to install new print...
|
Unix sort - left to right
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |