January 26th, 2004, 11:27 AM
replace "|" with empty space
I have a problem with the special character "|". The problem is in subject feild it is displaying
i have to replace the "|" with blank space can you help me out please it is very very urgent for me
January 26th, 2004, 10:23 PM
Assuming that you have a file containing these '|'s then
probably the easiest way to fix the problem is to use
sed -e 's/\|/ /g' filename
or to save output to a file
sed -e 's/\|/ /g' filename > newfilename
January 27th, 2004, 11:42 AM
Thanks for your help but when i use this command direct to the file it is giving an error as sed: command garbled: s/\|/ /g, or if i save this out put to a new file and use that file then it is not even displaying the error:Can't open filename. if you can please help me out in fixing this issue
January 27th, 2004, 12:28 PM
Finnbarr's commands are correct. With some *nix flavors you don't have to 'escape' the pipe charachter ( | vs \| ).
Are you trying to do this from the command line or a shell script?
Can you post the code you tried to execute that failed?
January 27th, 2004, 01:21 PM
Thanks for your response here is part of script which im trying to execute
1)SUBJECTLN="`date +%m/%d/%y::%H:%M`:Order Activity Report ("
where gxi is a text file with information stored as
3)mailx -s "$SUBJECT" "$ADDRESSES"
now in subject field it is printing as
01/26/04::11:44:Order Activity Report (abc|efg|.....)
i should replace that pipe in (abc|efg|.....) and print as (abc efg ....).
I tryed to use it in shell script rather than on command line but it is not working out for me.
Last edited by riaz_mohd; January 27th, 2004 at 01:28 PM.
January 27th, 2004, 01:42 PM
This works on my box:
The output is:
SUBJECTLN="`date +%m/%d/%y::%H:%M`:Order Activity Report ("
# gxi is file (filled with Foo|Bar|Foo|Bar)
SUBJECT=$SUBJECTLN`sed -e 's/|/ /g' $gxi`")"
# gxi declared in script
SUBJECT=$SUBJECTLN`echo $gxi | sed -e 's/|/ /g'`")"
01/27/04::19:41:Order Activity Report (Foo Bar Foo Bar)
01/27/04::19:41:Order Activity Report (Foo Bar)
As you can see I did not have to escape the pipe symbol.
January 27th, 2004, 01:49 PM
Thanks it is working really fine
Last edited by riaz_mohd; January 27th, 2004 at 02:56 PM.