UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old January 26th, 2004, 10:27 AM
riaz_mohd riaz_mohd is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 8 riaz_mohd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question replace "|" with empty space

Hi!

I have a problem with the special character "|". The problem is in subject feild it is displaying

abc@def.com|efg@ijk.com|.....

i have to replace the "|" with blank space can you help me out please it is very very urgent for me


Reply With Quote
  #2  
Old January 26th, 2004, 09:23 PM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 257 fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 23 h 46 sec
Reputation Power: 6
Assuming that you have a file containing these '|'s then
probably the easiest way to fix the problem is to use
sed(1) i.e.

sed -e 's/\|/ /g' filename

or to save output to a file

sed -e 's/\|/ /g' filename > newfilename

- Finnbarr

Reply With Quote
  #3  
Old January 27th, 2004, 10:42 AM
riaz_mohd riaz_mohd is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 8 riaz_mohd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi! Finnbarr,
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

Reply With Quote
  #4  
Old January 27th, 2004, 11:28 AM
druuna druuna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 137 druuna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 37 sec
Reputation Power: 0
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?

Reply With Quote
  #5  
Old January 27th, 2004, 12:21 PM
riaz_mohd riaz_mohd is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 8 riaz_mohd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi! Finnbarr's,
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 ("
2)SUBJECT=$SUBJECTLN$gxi")"
where gxi is a text file with information stored as
abc|efg|.....
3)mailx -s "$SUBJECT" "$ADDRESSES"

now in subject field it is printing as

OUTPUT

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 12:28 PM.

Reply With Quote
  #6  
Old January 27th, 2004, 12:42 PM
druuna druuna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 137 druuna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 37 sec
Reputation Power: 0
This works on my box:
Code:
#!/bin/sh

SUBJECTLN="`date +%m/%d/%y::%H:%M`:Order Activity Report ("

# gxi is file (filled with Foo|Bar|Foo|Bar)
gxi=/home/user/infile
SUBJECT=$SUBJECTLN`sed -e 's/|/ /g' $gxi`")"
echo $SUBJECT

# gxi declared in script
gxi="Foo|Bar"
SUBJECT=$SUBJECTLN`echo $gxi | sed -e 's/|/ /g'`")"
echo $SUBJECT


The output is:
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.

Reply With Quote
  #7  
Old January 27th, 2004, 12:49 PM
riaz_mohd riaz_mohd is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 8 riaz_mohd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks it is working really fine

Last edited by riaz_mohd : January 27th, 2004 at 01:56 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > replace "|" with empty space


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway