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
Removing text from a line in a file outthere_3 Shell Programming and Scripting 10 02-13-2008 03:38 AM
Removing empty spaces and adding commas jazz High Level Programming 4 11-13-2006 09:54 AM
Removing a particular line from a text file sendhilmani123 Shell Programming and Scripting 5 05-31-2006 09:32 AM
Padding zeros after removing commas in file pranag21 HP-UX 1 11-09-2005 10:22 PM
Removing lines in a text file. WABonnett Shell Programming and Scripting 4 11-25-2003 11:27 AM

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 Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 03-24-2003
hcclnoodles hcclnoodles is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 272
removing commas from text file

Dear all

I have a file which looks like this

xxxxxxxxxxxxxx,xxx,xxxxxxxxxx
xxxxxxxxxxxxxx,xxx,xxxxxxxxxx

etc

basically 14 characters then a comma, three characters, then a comma then 10 characters. We are uploading this file to our mainframe and they want the commas removed, so it looks like this

xxxxxxxxxxxxxxxxxxxxxxxxxxx

Has anybody got any ideas on how to do this?. Note, the file will always be the same format, but will vary in the number of lines


Any help would be greatly appreciated
  #2 (permalink)  
Old 03-24-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Well, here's one way:

Code:
sed -e 's/xxxxxxxxxxxxxx,xxx,xxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxx/' some_file > TMP_00
cp TMP_00 some_file
rm TMP_00
  #3 (permalink)  
Old 03-24-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,124
That sed solution will work only if each line literally contains those x's.

To get rid of all commas in a file, change that to:

sed 's/,//g' some_file > TMP_00
  #4 (permalink)  
Old 03-24-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
wow i must be tired.. your solution looks much better perderabo
  #5 (permalink)  
Old 03-25-2003
s93366's Avatar
s93366 s93366 is offline
Registered User
  
 

Join Date: Apr 2002
Location: Sweden / Stockholm
Posts: 168
or you can use the tr command

cat test.txt|tr -d , > out.txt

Have fun!
/Peter
  #6 (permalink)  
Old 03-26-2003
hcclnoodles hcclnoodles is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 272
Thanks Guys, that now works

regards
  #7 (permalink)  
Old 03-26-2003
WIntellect's Avatar
WIntellect WIntellect is offline
Registered User
  
 

Join Date: Sep 2002
Location: United Kingdom
Posts: 170
Quote:
Originally posted by Perderabo
sed 's/,//g' some_file > TMP_00
For a bit of fun (mine) the "perl" version is VERY similar to the sed version:
Code:
perl -pe 's/,//g;' < some_file > TMP_00
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 01:02 AM.


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