LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 04-28-2004, 02:48 PM   #1
sphynx
Member
 
Registered: Feb 2002
Location: /usr/home
Distribution: Ubuntu / Gentoo / Whatever
Posts: 67

Rep: Reputation: 15
sed question


Just started with sed. given a file

Fruit Price/lbs
Banana 0.89
Peach 0.79
Kiwi 1.50
Pineapple 1.29
Apple 0.99
Mango 2.29



i want to put a $ in front of all the amounts. there are two tabs between the two columns. anyone know how to put the $ in there? if necessary i could make the colums separated by a single space or one tab, but using two tabs keeps it looking orderly. I can't seem to find anything on how to put a $ in there using sed (and it must be sed).
thanks in advance.
 
Old 04-28-2004, 03:01 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Must be sed = homework? :)


Cheers,
Tink
 
Old 04-28-2004, 03:05 PM   #3
sphynx
Member
 
Registered: Feb 2002
Location: /usr/home
Distribution: Ubuntu / Gentoo / Whatever
Posts: 67

Original Poster
Rep: Reputation: 15
yeah its a lab that we are doing. i have looked around and read the book, and found insert, change, substitute, append... only substitute or change looks like it will actually change the two tabs into two tabs with a $. but i can't seem to find how to specify the tabs. everytime i try i screw up the file.
 
Old 04-28-2004, 03:20 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
sed 's/\([0-9]*\.[0-9]*\)/$&/' fruit.txt

Seems to work for me :)



Cheers,
Tink
 
Old 04-28-2004, 03:41 PM   #5
sphynx
Member
 
Registered: Feb 2002
Location: /usr/home
Distribution: Ubuntu / Gentoo / Whatever
Posts: 67

Original Poster
Rep: Reputation: 15
lol well that works.
Code:
sed 's/\([0-9]*\.[0-9]*\)/$&/' fruit.txt
thanks tink. my GPA thanks you too
 
Old 04-28-2004, 06:20 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Pleasure, and what does GPA stand for?



Cheers,
Tink
 
Old 04-28-2004, 06:25 PM   #7
sphynx
Member
 
Registered: Feb 2002
Location: /usr/home
Distribution: Ubuntu / Gentoo / Whatever
Posts: 67

Original Poster
Rep: Reputation: 15
my grade point average
 
  


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
sed question ckoniecny Linux - General 3 11-11-2005 09:31 AM
question on sed tifu Linux - Newbie 3 03-18-2005 04:38 PM
sed question virendratp Programming 3 09-10-2004 03:21 AM
little sed question freelinuxcpp Linux - Software 3 01-20-2004 07:36 AM
sed question zoomzoom Linux - Software 2 10-20-2003 04:04 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:32 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
Open Source Consulting | Domain Registration