The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
strip first 4 and last 2 lines from a file using perl meghana Shell Programming and Scripting 10 02-01-2008 06:01 PM
How to strip non numerical data out of file? Juha Shell Programming and Scripting 10 01-09-2007 04:09 AM
How to strip the contants from a file isingh786 UNIX for Dummies Questions & Answers 2 12-16-2005 04:11 PM
how to strip out the contents of file using grep isingh786 UNIX for Dummies Questions & Answers 11 11-28-2005 04:09 PM
trying to strip the first 4 char. of a file out via commandline Optimus_P UNIX for Dummies Questions & Answers 2 06-12-2001 10:02 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-22-2005
Registered User
 

Join Date: Feb 2005
Posts: 4
How to strip apostrophe from a file

I am trying to remove or replace various extraneous characters from a file so that subsequent processes work correctly. The characters that is giving me trouble is the apostrophe '.

The command I 'm trying is
sed 's/\'//g' ${IN_WRK_DIR}/file1 > ${IN_WRK_DIR}/file2
in a Korn script on HP Unix.

I do need to retain other nonalpha-numeric characters.
Reply With Quote
Forum Sponsor
  #2  
Old 06-22-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Check out this URL...it had helped me sometime back. I came across something similiar.

http://answers.google.com/answers/threadview?id=496910

Vino
Reply With Quote
  #3  
Old 06-22-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
Sometimes tr is easier to use than sed for single characters:
Code:
cat filename | tr -s "\'" ' '
Reply With Quote
  #4  
Old 06-22-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
Quote:
Originally Posted by jim mcnamara
Sometimes tr is easier to use than sed for single characters:
Code:
cat filename | tr -s "\'" ' '
<UUOC police>
tr -s "\'" ' ' < filename
</UUOC police>
Reply With Quote
  #5  
Old 06-22-2005
Registered User
 

Join Date: Feb 2005
Posts: 4
Thanks for the suggestions

tr works like a charm. As always syntax is everything.
Reply With Quote
  #6  
Old 06-22-2005
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
Quote:
Originally Posted by vgersh99
<UUOC police>
tr -s "\'" ' ' < filename
</UUOC police>
Actually, I don't think so: < opens the file and reads it. So does does cat. tr uses stdin no matter. If it were sed I'd agree.
Reply With Quote
  #7  
Old 06-22-2005
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,644
But in using cat you cat have to make fork and exec system calls for the new process, both are expensive calls, by using < to redirect stdin you do not need to make these calls and so as vergsh99 pointed out it would be a UUOC.

Why do you think it would be any different if it were sed?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0