want to escape forward slash, i tired but not working.. statement garbled
Hi Team,
could you please help on below? I am trying to use sed command to repalce one string with other but somehow replacement string contains forwards slash hence getting the error statement garbled! please help from_row contains /wu9m<h-8$ Fix is require at sql_text=`cat $staging_population_program | head -$before_lines | sed "s/\&\&1/$from_row/" | sed "s/\&\&2/$to_row/" | sed "s/\&\&3/$region/"` nygespappd29:/data/apps/pnbos/scripts > ./populate_staging_posn.ksh -C /data/apps/pnbos/config/HK_EOD.cfg -f C ALCSTG START ./populate_staging_posn.ksh at Monday, May 2, 2011 03:07:30 PM BST --> Running Staging POSN for ASIA at Monday, May 2, 2011 03:07:30 PM BST --> Loading profit centres at Monday, May 2, 2011 03:07:30 PM BST --> Splitting for multiple engines at Monday, May 2, 2011 03:07:48 PM BST --> Running multiple engines at Monday, May 2, 2011 03:07:51 PM BST sed: command garbled: s/\&\&2//wu9m<h-8$/ sed: command garbled: s/\&\&2//wu9m<h-8$/ sed: command garbled: s/\&\&1//wuCm<h-8$/ sed: command garbled: s/\&\&1//wuCm<h-8$/ |
First of all, please use [code][/code] tags around your code, to preserve formatting and to improve readability.
As for your problem, sed can use any basic ascii character as a separator, not just "s/x/y/". Try using "s|x|y|" instead, for example. Also, $(..) is recommended over `..` PS: sed also has a -e option for applying multiple expressions at once. No need to pipe it through three instances. |
It is still not working, I tried what you have suggested:
Code:
Code:
#!/bin/ksh Quote:
|
In the first sed "s|to_row|$from_row" is missing the closing | so it errors.
In the second it is not so it doesn't error and starts reading stdin -- which does not come. Try sed "s|to_row|$from_row|" some_file_name |
Quote:
Code:
rob@rob-debian:~$ sed "s|$to_row|$from_row|" Code:
#!/bin/bash |
All times are GMT -5. The time now is 01:05 AM. |