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
Simple Question aforball UNIX for Dummies Questions & Answers 3 03-04-2008 12:26 PM
simple sed question funksen Shell Programming and Scripting 10 04-08-2007 02:54 PM
Simple C question... Hopefully it's simple Xeed High Level Programming 6 12-15-2006 10:29 AM
Ok simple question for simple knowledge... Corrail UNIX for Dummies Questions & Answers 1 11-28-2005 09:03 AM
Simple ksh question frustrated1 Shell Programming and Scripting 1 11-05-2003 08:41 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-28-2007
Registered User
 

Join Date: Mar 2007
Posts: 17
sed - simple question

Hello

My file looks like that =>

12.56 have then 7888778.2566 what 44454.54545
878787.66565 if else 4445.54545455

I want to change all '.' on ',' .
I'm trying to do it with sed but I don't know chow to build regular expression to
change 454.4466 on 454,4466 ?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-28-2007
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
tr '.' ',' < infile > outfile
Reply With Quote
  #3 (permalink)  
Old 03-28-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,434
Code:
sed 's/\./,/g'
Got to put a backslash before "." to indicate an actual dot.
Reply With Quote
  #4 (permalink)  
Old 03-28-2007
Registered User
 

Join Date: Mar 2007
Posts: 17
wrong answer ..

sed 's/\./,/g' - the command change all '.' on ',' in the file , but I want change
only dots in numbers .
Reply With Quote
  #5 (permalink)  
Old 03-28-2007
Am not alone now!!!!
 

Join Date: Feb 2007
Location: Cochin, India
Posts: 248
Code:
sed 's/[0-9]\.[0-9]/,/g' filename
Reply With Quote
  #6 (permalink)  
Old 03-28-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Quote:
Originally Posted by scotty_123
sed 's/\./,/g' - the command change all '.' on ',' in the file , but I want change
only dots in numbers .
Code:
sed -e "s/\([0-9]\)\./\1,/g" -e "s/\.\([0-9]\)/,\1/g" file
Reply With Quote
  #7 (permalink)  
Old 03-28-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Quote:
Originally Posted by jacoden
Code:
sed 's/[0-9]\.[0-9]/,/g' filename
This will remove numbers before and after dot
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:16 AM.


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

Content Relevant URLs by vBSEO 3.2.0