Using sed how to remove "forward shash"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using sed how to remove "forward shash"
# 1  
Old 11-02-2017
Using sed how to remove "forward shash"

I am trying to remove "forward shash" using sed it was not working

Code:
666,server1, 00973 N/A RDF1+TDEV RW 1035788

i need to remove " N/A" and "RW"
I need output
Code:
666,server, 00973 , RDF1+TDEV , 1035788

# 2  
Old 11-02-2017
Hello ranjancom2000,

Could you please try following.
Code:
sed 's/N\/A/,/;s/RW/,/'   Input_file

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 11-02-2017
thanks great working
# 4  
Old 11-02-2017
Remember that sed's substitute command allows almost any delimiter to allow for flexibility. So for instance any of the following may be used:
Code:
sed 's^N/A^,^;s^SW^,^'
sed 's!N/A!,!;s!SW!,!'
sed 's|N/A|,|;s|SW|,|'
sed  's|N/A|,|;s/SW/,/'

You will notice that in the first three examples I use the same delimiter for consistency; but for the last one I switch back to the familiar delimiter for readability. This can only be done because there are two commands in the sed invocation.

Andrew
This User Gave Thanks to apmcd47 For This Post:
# 5  
Old 11-02-2017
If your sed version allows for EREs ("extended RE"), try
Code:
sed -r 's:N/A|RW:,:g' file
666,server1, 00973 , RDF1+TDEV , 1035788

This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk,sed : change every 2nd field ":" to "|"

Hi Experts, I have a string with colon delimited, want 2nd colon to be changed to a pipe. data: 101:8:43:4:72:14:41:69:85:3:137:4:3:0:4:0:9:3:0:3:12:3: I am trying with sed, but can change only 1 occurance: echo "101:8:43:4:72:14:41:69:85:3:137:4:3:0:4:0:9:3:0:3:12:3:" | sed 's/:/|/2'... (5 Replies)
Discussion started by: rveri
5 Replies

2. Post Here to Contact Site Administrators and Moderators

Suggestion: adding two new groups "sed" and "awk"

Majority of the questions are pertaining file/string parsing w.r.t sed or awk It would be nice to have these two as their own sub category under shell-programming-scripting which can avoid lot of duplicate posts. (1 Reply)
Discussion started by: jville
1 Replies

3. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

4. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Simplify Bash Script Using "sed" Or "awk"

Input file: 2 aux003.net3.com error12 6 awn0117.net1.com error13 84 aux008 error14 29 aux001.ha.ux.isd.com error12 209 aux002.vm.ux.isd.com error34 21 alx0027.vm.net2.com error12 227 dux001.net5.com error123 22 us008.dot.net2.com error121 13 us009.net2.com error129Expected Output: 2... (4 Replies)
Discussion started by: sQew
4 Replies

7. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

8. Shell Programming and Scripting

How to remove "New line characters" and "spaces" at a time

Dear friends, following is the output of a script from which I want to remove spaces and new-line characters. Example:- Line1 abcdefghijklmnopqrstuvwxyz Line2 mnopqrstuvwxyzabcdefghijkl Line3 opqrstuvwxyzabcdefdefg Here in above example, at every starting line there is a “tab” &... (4 Replies)
Discussion started by: anushree.a
4 Replies

9. Shell Programming and Scripting

sed remove date ex. "Mar 25 2008"

is there any way to remove data out of a file with sed? sample file: 2 3 414 Mar 25 2008 223 312 4244 Feb 25 2008 5 312 422344 Sept 25 2008 output: 2 3 414 223 312 4244 5 312 422344 (14 Replies)
Discussion started by: katrvu
14 Replies
Login or Register to Ask a Question