LinuxQuestions.org
Visit the LQ Articles and Editorials section
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, 03: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 07:29 PM.
 
Old 02-02-2007, 04:38 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
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, 07: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, 09:39 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 06:08 AM
Sed(?); Appending a comma-delineated file ice_hockey Linux - General 2 05-27-2005 09:42 AM
How to replace spaces in filenames with underscores rosslaird Linux - Software 4 02-22-2005 02:08 AM
Reading comma-separated data from file MeLassen Programming 4 04-04-2004 03:41 PM
comma delimited file cdragon Programming 5 06-21-2002 08:55 PM


All times are GMT -5. The time now is 01:48 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration