Problem in executing sed command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in executing sed command
# 1  
Old 05-18-2011
Problem in executing sed command

Hi,

Input: XX = to_date ('9999-12-31 23:59:59', 'YYYY-MM-DD HH24:MI:SS')

Required output: XX=to_date (\'9999-12-31 23:59:59\', \'YYYY-MM-DD HH24:MI:SS\')


Regards
Akshu
# 2  
Old 05-18-2011
Code:
XX= echo $XX|sed 's/*situation now*/*what you want*/'

would probably work
This User Gave Thanks to metal005 For This Post:
# 3  
Old 05-18-2011
Code:
sed "s/ = /=/;s/'/\\\'/g" infile

Code:
# cat tst
XX = to_date ('9999-12-31 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
# sed "s/ = /=/;s/'/\\\'/g" tst
XX=to_date (\'9999-12-31 23:59:59\', \'YYYY-MM-DD HH24:MI:SS\')

This User Gave Thanks to ctsgnb For This Post:
# 4  
Old 05-18-2011
Quote:
Originally Posted by ctsgnb
Code:
sed "s/ = /=/;s/'/\\\'/g" infile

Code:
# cat tst
XX = to_date ('9999-12-31 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
# sed "s/ = /=/;s/'/\\\'/g" tst
XX=to_date (\'9999-12-31 23:59:59\', \'YYYY-MM-DD HH24:MI:SS\')

Thanks It works fine!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing sed command inside a bash script

I want to run commands inside a bash script. An example is I want to pass the command in a string as regexp as an argument to the script, then run sed on the bash variable sed.sh regexp sed.sh "-i \"s/<p>//g\"" then call sed "$regexp" $fl (3 Replies)
Discussion started by: Kangol
3 Replies

2. UNIX for Dummies Questions & Answers

sed command problem

Hi i am reading a tutorial on sed below command was given in tutorial. i am not able to understand the working of below command also this command is now working in my enviroment. $ sed -n '1~2p' alarm sed: 1: "1~2p": invalid command code ~ $ need your assitance here (7 Replies)
Discussion started by: scriptor
7 Replies

3. Fedora

Problem Executing "lvcreate" Command

Hi everyone, I use Fedora 17. I used gparted to created a dev/sdb2 partition. I then used vgextend to extend the volume group. The output of vgdisplay shows the condition of my volume group: --- Volume group --- VG Name vg_data System ID Format ... (2 Replies)
Discussion started by: mojoman
2 Replies

4. Shell Programming and Scripting

Problem Executing Firmware Command using Shell Script

Guys, I have a script that should change one of the configuration Parameter in a http accelerator, this config change which will halt http traffic into device. So I have designed a script which should do these changes. But after executing this script, found that one of the input variable is not... (8 Replies)
Discussion started by: raghunsi
8 Replies

5. UNIX for Dummies Questions & Answers

Problem with executing command inside a cron job

Hi All, I have scheduled a script in cron which writes output to the below file. ....>> /data/Target/wrapper_invoke_ds_job_`date '+%Y%m%d'`.ksh_out 2>&1 But the date command is not getting resolved in the format specified. It just resolves to the following. wrapper_invoke_MQ_ds_job_Tue... (3 Replies)
Discussion started by: pkm_oec
3 Replies

6. UNIX for Dummies Questions & Answers

Problem with sed command

Hi, I used sed command to replace õ character. sed -n '1,$s/õ/o/gp' inputfile > outputfile The problem is there are 5 records in input file and 2 records has that õ character. So after using the sed command, in output file Iam getting only those records which has character õ replaced by o.... (2 Replies)
Discussion started by: manneni prakash
2 Replies

7. UNIX for Dummies Questions & Answers

Problem executing find file command in Linux

When trying to find a list of files with specific text in them using find . -type f -exec grep -l "DataStage Job 4263" {}\; I get error find: missing argument to 'exec' How can I correct this ? I'm on Linux Red Hat. Cheers PS I'm a DataStage programmer not a systems support... (4 Replies)
Discussion started by: jackdaw_at_work
4 Replies

8. Shell Programming and Scripting

problem in sed command

Hi, i have a script to replace a string. $ cat List.txt /DIR1/DIR2/DIR3/abcdefgh /DIR1/DIR2/DIR3/abcd /DIR1/DIR2/DIR3/abcdefghijk /DIR1/DIR2/DIR3/xyz $ ind=`/DIR1/DIR2/DIR3/abcd` $ replace=`#/DIR1/DIR2/DIR3/abcd` $ sed "s|$find|$replace|g" List.txt>cat NewList.txt The aim of... (3 Replies)
Discussion started by: tsaravanan
3 Replies

9. UNIX for Dummies Questions & Answers

SED command is not executing within the shell

Hallo everybody I am having a shell script called auto_run.sh in that only the first line works. the second line which has sed command is working only at the # prompt. not within the shell script. Your help is highly appreciated.Thank you in advance. exec auto_inv.4ge >KTI sed 's/ //g'... (1 Reply)
Discussion started by: naushad
1 Replies

10. Shell Programming and Scripting

Sed command problem

Hi! here is my problem : $ more file yopyop:FIToB8df02f:10200:351:yoyo:/home/yopyop:/usr/bin/ksh $grep yopyop file | sed s/FIToB8df02f/passe/ yopyop:passe:10200:351:yoyo:/home/yopyop:/usr/bin/ksh $more file yopyop:FIToB8df02f:10200:351:yoyo:/home/yopyop:/usr/bin/ksh ...when i... (1 Reply)
Discussion started by: tomapam
1 Replies
Login or Register to Ask a Question