LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 03: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, 04:01 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,999
Blog Entries: 11

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


Cheers,
Tink
 
Old 04-28-2004, 04: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, 04:20 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,999
Blog Entries: 11

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

Seems to work for me :)



Cheers,
Tink
 
Old 04-28-2004, 04: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, 07:20 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,999
Blog Entries: 11

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



Cheers,
Tink
 
Old 04-28-2004, 07: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


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


All times are GMT -5. The time now is 10:18 PM.

Main Menu
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