ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
In a kornshell script I am trying to do a search and replace of file path strings in multiple files. I try sed but it doesn't like the " at the end of my replacement string. It gives me the error "sed:extra text at end of command". How can I get around this? Thanks.
Thanks, I fixed that problem except i get an error not recognizing -e when I type
sed -e "s/^Data_filename = .*/Data_filename = \"Results\$filename\"/g" \
-e "s/^map_used = .*/map_used = $MAP/g" \
-e "s/^location = .*/location = $LOC/g" $I > temp
when I get rid of the map_used line it works, so what is going on? Thank you.
I want the replacement string to have the quotes; I tried defining MAP again like \"STRING\" but it still gives me that error not recognizing sed's -e extension.
Originally posted by ShaqDiesel Thanks, I fixed that problem except i get an error not recognizing -e when I type
sed -e "s/^Data_filename = .*/Data_filename = \"Results\$filename\"/g" \
-e "s/^map_used = .*/map_used = $MAP/g" \
-e "s/^location = .*/location = $LOC/g" $I > temp
when I get rid of the map_used line it works, so what is going on? Thank you.
I bet you've got a space after the backslash on the MAP line. The backslash must be the last character on the line. The shell is ending the sed command because the newline isn't escaped, and is trying to run the next line as a new command (-e: command not found).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.