The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find and replace javeed7 Shell Programming and Scripting 1 04-02-2008 06:00 AM
find and replace rakshit Shell Programming and Scripting 4 01-24-2008 12:52 AM
find and replace mahabunta UNIX for Dummies Questions & Answers 7 09-21-2006 09:05 AM
find and replace vikas_j@hotmail UNIX for Dummies Questions & Answers 3 02-25-2002 02:41 PM
Find & Replace gagansharma Shell Programming and Scripting 3 11-27-2001 01:17 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-17-2006
Registered User
 

Join Date: Jul 2006
Posts: 1
find and replace

I have a file that I want to remove all of the periods from. I am using the below to remove quotations and it works fine -I thought I could make it work for the period but it does not. Any help would be appreciated.


works to remove the double quote mark (")
sed -e 's/"//g' input file >output file

tried
sed -e 's/.//g' input file >output file

and
sed -e 's/"."//g' input file >output file

valhutch
Reply With Quote
Forum Sponsor
  #2  
Old 07-17-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,014
Code:
sed -e 's/[.]//g' input file >output file
Reply With Quote
  #3  
Old 07-28-2006
Registered User
 

Join Date: Jul 2005
Posts: 29
Hi

Hey What if you donot want to redirect the file and instead just read the existing file and replace what ever you wanna do and then save it ?....
any ideasss ??
Reply With Quote
  #4  
Old 07-28-2006
Supporter
 

Join Date: Jul 2006
Posts: 156
sed - edit files in place

Some versions of 'sed' support in-place editing using the '-i' option, while others do not.

An alternative is using perl from the command line ( assuming it's installed ), and using the '-i -pe' options.

'-i' edits files in place.
'-e' allows you to define Perl code to be executed
'-p' loops around every line in the file and performs the substitution

This will remove all period characters from the file "input_file".
Code:
perl -i -pe 's/[.]//g' input_file
Also, in response to the original message, you can also escape the '.' character with a backslash.

Code:
sed -e 's/\.//g'
This is because in regular expression language, the period is a special character which represents "any character", so if you want it to represent a literal period, it must be escaped.
Reply With Quote
  #5  
Old 07-29-2006
Hitori's Avatar
Registered User
 

Join Date: Jun 2006
Posts: 360
The new -i option for sed stands for edit files in place:

$ sed -i -e 's/\.//g' input_file

Note:
$ sed --version
GNU sed version 4.1.5


Your sed may not have this option
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:21 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