sed
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.
|
Maybe you must escape the " sign. Can you post your command?
Or you can try the cut command. You can cut on character positions: echo $line | cut -cPOS1-POS2 or on distinct signs echo $line | cut -d/ -f1-3 |
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. |
That could be due to the contents of $MAP. please 'echo $MAP' for us here. :)
|
It is a constant I defined in the beginning: $MAP='"4RFh\,SAHg\,tBds"'
|
Your constant makes the line look like:
Code:
-e "s/^map_used = .*/map_used = "4RFh\,SAHg\,tBds"/g" \ When you define MAP, try escaping the double-quotes. |
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.
|
You may need two backslashes when escaping it. I have to play around with those sometimes. What is the exact text of the error you get?
|
Quote:
|
All times are GMT -5. The time now is 05:46 AM. |