The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-13-2007
Registered User
 

Join Date: Sep 2006
Posts: 90
maybe sed, maybe ex?

I have a file containing the following line:

dn: employeeNumber=xxxxxxx, c=us, ou=people, o=xxx.com

After the first comma, there are 2 spaces, i want to get rid of them.

After the 2nd and 3rd comma, there is one space, i want to get rid them also.

All in all, i would like the line to look like this

dn: employeeNumber=xxxxxxx,c=us,ou=people,o=xxx.com

Any help is appreciated. Thanks.

-S
Reply With Quote
Forum Sponsor
  #2  
Old 04-13-2007
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,644
editing the file in place:
Code:
perl -pi -e 's/, +/,/g' file
Reply With Quote
  #3  
Old 04-13-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,580
sed:
Code:
sed -i 's/, \{1,\}/,/g' file
Reply With Quote
  #4  
Old 04-17-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Code:
sed 's/, */,/g' filename
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 10:04 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