sed command on ksh

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed command on ksh
# 1  
Old 07-15-2011
sed command on ksh

How to use sed command to delete / and \ in a text...

# 2  
Old 07-15-2011
$ echo "\/" | sed -e 's,\/,,' -e 's,\\,,'

$ echo "\/"

This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 07-16-2011
echo '/ and \' | sed 's/[/|\]//g'

Last edited by Franklin52; 07-17-2011 at 07:28 AM.. Reason: Please use code tags for data and code samples, thank you
This User Gave Thanks to ltomuno For This Post:
# 4  
Old 07-16-2011
"tr" can be used instead of "sed" and would likely be faster:
echo '/ and \' | tr -d '\\/'

This User Gave Thanks to jlliagre For This Post:
# 5  
Old 07-18-2011
Thanks for all your help! It works...
# 6  
Old 07-18-2011
Originally Posted by ltomuno
echo '/ and \' | sed 's/[/|\]//g'

We do not actually require symbol | in the sed command.
echo '/ and \' | sed 's/[\/]//g'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Help needed - ksh: sed: command garbled:

Hi all, What am I doing wrong here? $ cat test_sed.ksh #!/usr/bin/ksh var="sed -e \'6s/9/6/\' testfile.txt > testfile.txt.2" $var $ ./test_sed.ksh sed: command garbled: \'6s/9/6/\' Thank you! (4 Replies)
Discussion started by: ejianu
4 Replies

3. Shell Programming and Scripting

Using Sed to do a substitution inside ksh

I'm trying to do an ls from inside of a ksh script. I loop through the results one line at a time and attempt to do a substitution using sed to convert YYYYMMDD from the older files into the newer files. Basically sometimes the ETL load runs over midnight and half the files are off by one day... (3 Replies)
Discussion started by: Calbrenar
3 Replies

4. Shell Programming and Scripting

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: sed 's/ERROR/ a\hoi' file sed 's/ERROR/ a\ hoi' file I get all the time the error sed:... (7 Replies)
Discussion started by: Alex400
7 Replies

5. Shell Programming and Scripting

KSH: substitution character, AWK or SED?

Hi Gurus, I am working with a korn shell script. I should replace in a very great file the character ";" with a space. Example: 2750;~ 2734;~ 2778;~ 2751;~ 2751;~ 2752;~ what the fastest method is? Sed? Awk? Speed is dead main point, Seen the dimensions of the files Thanks (6 Replies)
Discussion started by: GERMANICO
6 Replies

6. Shell Programming and Scripting

sed problem in ksh

Hi, I have the following issue while replacing text in a file usind sed $ cat file $ One,ABCD\XYZ,Server one i want to replace ABCD\XYZ with another text SERVER. with ABCD\XYZ stored in a variable. #!/bin/ksh VAR=ABCD\XYZ echo $VAR cat file | sed 's/'"$VAR"'/SERVER/' ... (14 Replies)
Discussion started by: sudheer1984
14 Replies

7. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

8. Shell Programming and Scripting

passing variables to sed in ksh

Hi, i need help passing variables to sed using ksh. My goal is to get particular data from log files. first i put a mark to the log files. echo "TEST_"`date + %m_%d_%Y_%T"` >markFile this will produce a 'markFile' which contain text like this TEST_06_01_2009_21:55:09 then i put the mark... (2 Replies)
Discussion started by: d.anggrianto
2 Replies

9. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

10. Shell Programming and Scripting

appending a file using sed in ksh

i am trying to append a 5 line SGML file(file1) with a 500,000 line SGML file (file2). file1 is a template, so i wish to preserve. i only want to add lines 5 to the end of file2. i have: cp file1 temp1 sed -n '5,$p' file2 >> temp1 when i check the tail of temp1, i consistantly find the... (3 Replies)
Discussion started by: smac
3 Replies
Login or Register to Ask a Question