LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-02-2007, 02:51 PM   #1
ferradura
Member
 
Registered: Jun 2006
Location: PT
Distribution: CRUX & Slackware
Posts: 100

Rep: Reputation: 15
Cool need to replace spaces with comma (ascii file) - DONE!


i have a 40 MB ascii file, with millions of numerical characters.
i needed to change it`s format,replacing the spaces in it with a ; or , or even |
Ex.:

3.36700000 -0.29860000 3.13370000 179 179 179
to
3.36700000;-0.29860000;3.13370000;179;179;179

Does any one know a simple script to speed up the process? Something in bash would do it...

Thanks

Last edited by ferradura; 02-02-2007 at 06:29 PM.
 
Old 02-02-2007, 03:38 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
This doesn't take international characters or multiple spaces, etc. into account:
Code:
$ sed 's/ /;/g' test.log > testnew.log
$ cat test.log
3.36700000 -0.29860000 3.13370000 179 179 179
$ cat testnew.log
3.36700000;-0.29860000;3.13370000;179;179;179
 
Old 02-02-2007, 06:27 PM   #3
ferradura
Member
 
Registered: Jun 2006
Location: PT
Distribution: CRUX & Slackware
Posts: 100

Original Poster
Rep: Reputation: 15
Awesome, it took 5 seconds to process the whole file.
Thank YOU!!!!!!!!!

You got to love Slackers!

Quote:
Originally Posted by gilead
This doesn't take international characters or multiple spaces, etc. into account:
Code:
$ sed 's/ /;/g' test.log > testnew.log
$ cat test.log
3.36700000 -0.29860000 3.13370000 179 179 179
$ cat testnew.log
3.36700000;-0.29860000;3.13370000;179;179;179
 
Old 02-02-2007, 08:39 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
No problem - glad it did the job
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i change spaces inside a txt file, and replace space with backslash \? repolona Linux - Newbie 1 05-24-2006 05:08 AM
Sed(?); Appending a comma-delineated file ice_hockey Linux - General 2 05-27-2005 08:42 AM
How to replace spaces in filenames with underscores rosslaird Linux - Software 4 02-22-2005 01:08 AM
Reading comma-separated data from file MeLassen Programming 4 04-04-2004 02:41 PM
comma delimited file cdragon Programming 5 06-21-2002 07:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration