LinuxQuestions.org
Help answer threads with 0 replies.
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-15-2004, 05:35 PM   #1
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Rep: Reputation: 15
sed problem


Hi, have been working through some examples to get the hang of sed when I came upon this one which doesnt seem to work.

" sed -n '/ 0\.[0-9] [0-9]$/p' fruit_prices.txt "
running this command is supposed to output

Banana 0.89
Paech 0.79
Apple 0.99

However all I get is the prompt.

here is the link to the site:

http://kristi.erdves.lt/books/Comput...6/251-254.html


[root@jekyll test]# ls -l
total 8
-rw-r--r-- 1 root root 101 Sep 16 09:48 fruit_prices.txt
-rw-r--r-- 1 root root 36 Sep 14 18:12 regexp.txt
[root@jekyll test]# cat fruit_prices.txt
Fruit Price/lbs
Banana 0.89
Paech 0.79
Kiwi 1.50
Pineapple 1.29
Apple 0.99
Mango 2.20
[root@jekyll test]# sed '/ 0\.[0-9] [0-9]$/p' fruit_prices.txt
Fruit Price/lbs
Banana 0.89
Paech 0.79
Kiwi 1.50
Pineapple 1.29
Apple 0.99
Mango 2.20
[root@jekyll test]# sed -n '/ 0\.[0-9] [0-9]$/p' fruit_prices.txt
[root@jekyll test]#
 
Old 09-15-2004, 05:46 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
This example has one space to many:

Original:
sed -n '/ 0\.[0-9] [0-9]$/p' fruit_prices.txt

The way it should be (and is on the given url):
sed -n '/ 0\.[0-9][0-9]$/p' fruit_prices.txt

I must admid that it looks like there's a space, but if you copy/paste it from the page, there's none
 
Old 09-15-2004, 06:33 PM   #3
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
Thanks for the reply, actually it was that space and

the space before the first zero: sed -n '/ 0\.[0-9] [0-9]$/p' fruit_prices.txt

correct is : sed -n '/0\.[0-9][0-9]$/p' fruit_prices.txt

in the book there is a space before the zero.

WD

Last edited by Warmduvet; 09-15-2004 at 06:36 PM.
 
  


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 problem Miro1 Programming 3 04-09-2005 09:02 AM
a sed problem thanhVic Programming 5 03-02-2005 01:05 AM
sed problem fossilet Linux - Software 4 12-26-2004 05:44 AM
Help Sed Problem anirudh Linux User Groups (LUG) 1 08-30-2004 02:25 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM

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

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