LinuxQuestions.org
Register a domain and help support LQ
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 09-24-2009, 03:01 PM   #1
hawgwild
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 0
Help with a sed substitution string


I have a huge file and trying to sed to clean it up.

I have lines like the following
00000004590,59,59,0,9,0,1
I need this line to look like this
00000004590,0.59,0.59,0,9,0,1
The 59 in this case will be variable, but it will always be 2 digits. I need to remove the cent sign, and put 0. preceeding the 2 digit value there.
Please help with my substitution command, thanks
s//etc.
The 59 may not always be in the same place in the line, so referring to the end of line $ will probably not work.

Last edited by hawgwild; 09-24-2009 at 03:09 PM. Reason: addendum
 
Old 09-24-2009, 03:11 PM   #2
neeraj_sriva
LQ Newbie
 
Registered: Nov 2008
Posts: 6

Rep: Reputation: 1
It should work

sed 's/,\([0-9][0-9]\)/,0.\1/g'

from within vim

%s/,\([0-9][0-9]\)/,0.\1/g
 
Old 09-24-2009, 03:35 PM   #3
hawgwild
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Original Poster
Rep: Reputation: 0
thanks, that puts me on the right track
 
  


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
Problems with a substitution using sed wtaicken Programming 4 12-15-2008 05:04 AM
String Substitution Swapna173 Linux - Newbie 1 08-04-2008 07:22 AM
variable substitution in sed gaynut Programming 1 07-14-2008 08:38 AM
Substitution of a long string horacioemilio Programming 5 04-07-2008 10:21 PM
Complicated string substitution horacioemilio Programming 5 02-13-2008 07:40 PM


All times are GMT -5. The time now is 04:47 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration