Using sed how to remove "forward shash"

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

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

i need to remove " N/A" and "RW"
I need output

666,server, 00973 , RDF1+TDEV , 1035788

Hello ranjancom2000,

Could you please try following.

sed 's/N\/A/,/;s/RW/,/'   Input_file

Thanks,
R. Singh

1 Like

thanks great working

Remember that sed 's substitute command allows almost any delimiter to allow for flexibility. So for instance any of the following may be used:

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

1 Like

If your sed version allows for EREs ("extended RE"), try

sed -r 's:N/A|RW:,:g' file
666,server1, 00973 , RDF1+TDEV , 1035788
1 Like