LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 08-31-2004, 07:52 PM   #1
mikefazz
LQ Newbie
 
Registered: Aug 2004
Location: Seattle
Distribution: Mandrake 10.0
Posts: 5

Rep: Reputation: 0
Simple Text Reformat (sed and grep)


Hello,

I have been trying for some time to reformat an output text file into a different form. I have been trying sed and grep and continue to have difficulty. I would appreciate any input:

Convert:
(D16) - 29.8376244930393
(D17) - 17.97422743561405
(D18) 82.14585790008447

To:

- 29.8376244930393, - 17.97422743561405, 82.14585790008447
or
- 29.8376244930393
- 17.97422743561405
82.14585790008447

I have been having all sorts of problems with the negative sign. The command that should work is:

grep -o (-)\?[0-9]*\.[0-9]* || [0-9]*\.[0-9]* < Alpha.txt >> EulerAngles.txt

But it doesn't...

Thanks for the help, there must be a simple solutions to such a simple problem...


Mike
 
Old 08-31-2004, 08:03 PM   #2
ToniT
Senior Member
 
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
Code:
toni@mario:~/tst$ cat foo.txt
(D16) - 29.8376244930393
(D17) - 17.97422743561405
(D18) 82.14585790008447
toni@mario:~/tst$ cut -c7- foo.txt
- 29.8376244930393
- 17.97422743561405
82.14585790008447
toni@mario:~/tst$
 
Old 08-31-2004, 08:38 PM   #3
mikefazz
LQ Newbie
 
Registered: Aug 2004
Location: Seattle
Distribution: Mandrake 10.0
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks

Thanks ToniT,


I should have asked yesterday and averted the headache...

Mike
 
  


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
Simple grep command problem acis Linux - General 2 07-16-2004 01:21 PM
remove text with grep craigdolson Linux - General 6 04-21-2004 04:25 PM
Simple grep question - I hope ! MiguelE Linux - Newbie 3 04-16-2004 09:46 AM
sed & grep script? dolvmin Linux - Software 20 09-22-2003 07:30 AM
using sed, simple question bobthebat Programming 3 04-30-2001 11:01 PM


All times are GMT -5. The time now is 08:40 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