SED sub commands in KSH not working for me


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SED sub commands in KSH not working for me
# 1  
Old 09-02-2011
SED sub commands in KSH not working for me

I am using SED to edit a file (called file)
the file contains the word "ERROR"
and I want to use SED to:

1. Search for text "ERROR"
If found,
2. Append new line with text "hoi"

I tried:
Code:
sed 's/ERROR/ a\hoi' file
sed 's/ERROR/ a\ hoi' file

I get all the time the error
Code:
sed: 0602-404 Function s/ERROR/ a\ hoi cannot be parsed.

what am I doing wrong??? Smilie

Last edited by Franklin52; 09-02-2011 at 10:16 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 09-02-2011
Code:
sed "s/ERROR/\nhoi/" file

will it work?
# 3  
Old 09-02-2011
not working
# 4  
Old 09-02-2011
Same error? Because what You did try before could not work - You didn't close "s" command.
sed in ksh works pretty normal...
Code:
$ ksh
$ echo "1 2 3" | sed "s/2/\nhoi/"
1 
hoi 3

# 5  
Old 09-02-2011
not working: output
Code:
$ echo "1 2 3" | sed "s/2/\nhoi/"
1 nhoi 3


Last edited by Franklin52; 09-02-2011 at 10:16 AM.. Reason: Please use code tags for code and data samples, thank you
# 6  
Old 09-02-2011
Alex, are you in solaris ?
# 7  
Old 09-05-2011
nope AIX
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Tilde commands not working

Hi I have a script that it sends emails to various recipients using mailx, but some of the recipients should be sent as BCC, but ~b flag when used in the following line, does not put the gmail address as BCC: echo "node $output is down" | mailx -s "$output not pinging" sadf@xyz.com ~b... (8 Replies)
Discussion started by: fretagi
8 Replies

2. UNIX for Dummies Questions & Answers

ksh with Oracle commands

works fine. echo "Deleting CHOPOne Coreaccess from LAUA..." $ORACLE_HOME/bin/sqlplus username/password@servername << ! delete from usergrpdtl where username='acker'; commit; ! but not working with "if statement" even $TMPDIR/adlogin.log exists and greater than 0. if then ... (9 Replies)
Discussion started by: lawsongeek
9 Replies

3. Shell Programming and Scripting

sed commands success / fail from commandline vs ksh script

solaris 5.10 Generic_138888-03 sun4v sparc SUNW,Sun-Fire-T200 I need a sed command that tests true when presented with lines that contain either forward and backslash. input file: c:/myFile.txt c:\yourFile.txt It doesn't appear that sed (in my environment anyway) supports... (4 Replies)
Discussion started by: msutfin
4 Replies

4. Shell Programming and Scripting

sed command not working inside ksh script but works fine outside

Hi, I am a bit confused ,why would a sed command work fine outside of ksh script but not inside. e.g I want to replace all the characters which end with a value and have space at end of it. so my command for it is : sed -i "s/$SEPARATOR /$SEPARATOR/g" file_name This is working fine in... (8 Replies)
Discussion started by: vital_parsley
8 Replies

5. UNIX for Dummies Questions & Answers

Calling commands with ksh

Hi, I am not able to run below command on linux, it however works on solaris. If anyone knows the reason and a solution for it can you please let me know ? Linux ----- $> ksh 'echo hi' ksh: echo hi: No such file or directory $> which ksh /usr/bin/ksh Solaris ------ $> ksh 'echo... (2 Replies)
Discussion started by: krishnaux
2 Replies

6. Shell Programming and Scripting

Have to learn sed and awk commands in kSH?

Links Please??? (2 Replies)
Discussion started by: Diddy
2 Replies

7. UNIX for Advanced & Expert Users

Better KSH commands

Are there any documents available for checking the execution time taken by ksh commands? My requirement is to fine tune a set of shell scripts having lot of "echos" and "date"s. Is there a better replacement for the below code?. echo "ABC process started on `date`" some code.. echo... (12 Replies)
Discussion started by: engineer
12 Replies

8. Shell Programming and Scripting

sed not working on AIX in ksh shell!

Hi All, I have this script which doesn't work on AIX ksh shell.. # ! /usr/bin/ksh grep -irl "6000" /home/applmgr/xyz > file_list_port.log xargs sed -i 's/6000/6010/g' < file_list_port.log But this same script has worked perfectly on linux bash shell.. Could anyone please share... (4 Replies)
Discussion started by: a1_win
4 Replies

9. UNIX for Dummies Questions & Answers

ksh substring commands

I am trying to get various portions of strings in my script, but am getting a substitution error. I followed the syntax that was described when I goggled this, but I can't get anything to work. #! /bin/ksh/ hello="adklafk;afak" #hello=${hello:3} hello=${$hello:3} happy="hey" echo... (1 Reply)
Discussion started by: anderssl
1 Replies

10. Shell Programming and Scripting

ksh GUI commands

I have a few scripts that i would like to make into GUI's. Are there scripting commands to make GUI's if so where can i get the list of commands and what they do or if anyone has an example of it. Anything will help, thanks (1 Reply)
Discussion started by: daltonkf
1 Replies
Login or Register to Ask a Question