The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 09:00 AM
find and replace rakshit Shell Programming and Scripting 4 01-24-2008 03:52 AM
find and replace mahabunta UNIX for Dummies Questions & Answers 7 09-21-2006 12:05 PM
find and replace vikas_j@hotmail UNIX for Dummies Questions & Answers 3 02-25-2002 05:41 PM
Find & Replace gagansharma Shell Programming and Scripting 3 11-27-2001 04:17 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-17-2006
valhutch valhutch is offline
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
  #2 (permalink)  
Old 07-17-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
sed -e 's/[.]//g' input file >output file
  #3 (permalink)  
Old 07-28-2006
rosh0623 rosh0623 is offline
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 ??
  #4 (permalink)  
Old 07-29-2006
nathan nathan is offline VIP Member  
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.
  #5 (permalink)  
Old 07-29-2006
Hitori's Avatar
Hitori Hitori is offline Forum Advisor  
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
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0