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!

multiple sed needs. 1

Status
Not open for further replies.

CIMTEET

Programmer
Jun 25, 2001
182
US
This code does 3 things is cshell. It changes the SES_ID_INPUT, OUTPUT_FILE_NAME, and test text in an sql file prior to running it. So far I been unsuccessful in trying to trim this down into one statement.

cat gen_query.sql | sed 's/ SI'/SES_ID_INPUT/'$SES_ID'/'>junk
cat junk | sed 's/OUTPUT_FILE_NAME/'$NAME'/'>junk2
cat junk2 | sed 's/test/'$NAME'/'> $NAME.sql


I tried this

cat gen_query.sql | sed 's/ SI'/SES_ID_INPUT/'$SES_ID'/',sed 's/OUTPUT_FILE_NAME/'$NAME'/'>junk

hoping I could combine the two. I just don't like creating two files in order to get a third. Its like wearing socks in the bathtub, it just aint right. Any suggestions?

Greg
 
and I forgot to mention that the thing I tried the second time did not work.
 
What about this ?
sed "s/ SI/SES_ID_INPUT/$SES_ID/;s/OUTPUT_FILE_NAME/$NAME/;s/test/$NAME/" gen_query.sql > $NAME.sql

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Did that work for you? I got a suffix to large error.
 
That is an improved error. What I would try normally gave me a 'garbled' error.
 
What are the values of $SES_ID and $NAME ?
Anyway, I wonder this worked for you :
sed 's/ SI'/SES_ID_INPUT/'$SES_ID'/'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
So, again, what are the WORKING sed's you want to trim down in a single sed run ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The SI was actually a $SI, but yes it worked. The syntax is proper to my knowledge.
 
Here are the working lines:

cat test_convert_cos.sql | sed 's/SES_ID_INPUT/'$SES_ID'/'
> junk
cat junk | sed 's/OUTPUT_FILE_NAME/'$NAME'/'> junk2
cat junk2 | sed 's/test/'$NAME'/'> $NAME.sql

 
I copied over wrong at the very top. You were right, there is no 4th /
 
You may try this:
sed -e 's/SES_ID_INPUT/'$SES_ID'/' -e 's/OUTPUT_FILE_NAME/'$NAME'/' -e 's/test/'$NAME'/' test_convert_cos.sql > $NAME.sql


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top