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

Help with sed command

Status
Not open for further replies.

ISUTri

MIS
Mar 25, 2004
38
US
I am a newbie to Unix and sed so although I saw some posts that were similar to what I'm having problems with I couldn't get the suggestions to work with my problem.

I am modifying a previously built .prog that has a sed command in it that builds an ftp command when the .prog is ran. My problem is my ftp is different than the previous one. The previous ftp was hitting a website to pull information. I am looking to grab the information from a directory on a neighboring server.

I am getting a sed: -e expression #1, char 12: Extra characters after command error

below is my code where it would be Server:\FolderB in windows.

sed -e 's/hq-ftp1\\\\Server\\\\FolderA\\\\/g' \
-e "s~<USERID>~$ftp_user~g" \
-e "s~<PASSWD>~$ftp_user_pass~g" \
-e "s~<INFILE>~$input_filename~g" \
-e "~<FILEDIR>~Lease~g" \
-e "/<OUTFILE>/$new_file/g" < $XXHH_TOP/bin/sftp_get.exp.template > $APPLPTMP/$sftp_get_file

Thanks!
 
Hi

Missing delimiter in [tt]s///[/tt] syntax :
Code:
sed -e 's[COLOR=red yellow]/[/color]hq-ftp1\\\\Server\\\\FolderA\\\\[COLOR=red yellow]/[/color]g' \
There should be three delimiters.



Feherke.
 
Thanks for the tip. Now I'm getting a new error! Here's my revised code.


sed -e 's/<SITEID>/Server\\\\FolderA\\\\FolderB\\\\/g' \
-e "s~<USERID>~$ftp_user~g" \
-e "s~<PASSWD>~$ftp_user_pass~g" \
-e "s~<INFILE>~$input_filename~g" \
-e "~<FILEDIR>~Lease~g" \
e "/<OUTFILE>/$new_file/g" < $XXHH_TOP/bin/sftp_get.exp.template > $APPLPTMP/$sftp_get_file

This is the new error:

-e: not found
 
Replace this:
e "/<OUTFILE>/
with this:
-e "/<OUTFILE>/

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi

Code:
sed -e 's/<SITEID>/Server\\\\FolderA\\\\FolderB\\\\/g' \
-e "s~<USERID>~$ftp_user~g" \
-e "s~<PASSWD>~$ftp_user_pass~g" \
-e "s~<INFILE>~$input_filename~g" \
-e "[COLOR=red yellow]s[/color]~<FILEDIR>~Lease~g" \
[COLOR=red yellow]-[/color]e "[COLOR=red yellow]s[/color]/<OUTFILE>/$new_file/g" < $XXHH_TOP/bin/sftp_get.exp.template > $APPLPTMP/$sftp_get_file

Feherke.
 
OOps, seems I've missed some syntax issues ...
 
I'm sorry I uploaded the wrong error message. With the information above it's not the -e error it's the following one.

sed: -e expression #5, char 2: Unknown command: `<'


The -e occurs if I comment out the -e's in the middle of the script.

This is my code and I'm getting the unknown command error. Sorry about the confusion.


sed -e 's/<SITEID>/hq-ftp1\\\\InvoiceImport\\\\lease\\\\/g' \
-e "s~<USERID>~$ftp_user~g" \
-e "s~<PASSWD>~$ftp_user_pass~g" \
-e "s~<INFILE>~$input_filename~g" \
-e "~<FILEDIR>~Lease~g" \
-e "/<OUTFILE>/$new_file/g" < $XXHH_TOP/bin/sftp_get.exp.template > $APPLPTMP/$sftp_get_file

Thanks again
 
again:
-e "[!]s[/!]~<FILEDIR>~Lease~g" \

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That was it! The command line from feherke helped me get it working. I needed to put the s's that they highlighted in their code example along with that - in front of the last e.

Thanks everyone!
 
[rtfmp]probably you also needed to read the sed man page[/rtfmp] ;-)

HTH,

p5wizard
 
...and perhaps award festive stars for the help you have received?

The internet - allowing those who don't know what they're talking about to have their say.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top