LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 07-14-2006, 12:54 PM   #1
stevie_velvet
Member
 
Registered: Aug 2004
Location: Italia + UK
Distribution: RHEL 4 + Fedora FC5
Posts: 118

Rep: Reputation: 15
regular expressions ~ white spaces


this should be simple but it driving me....
i'm using grep -e (or egrep to only find 'ted-1' ~ but the white space isn't wokirng

from the file
ted-1 ted-11 ted-111


grep -e "ted-1[\s]" file


ta for any help
 
Old 07-14-2006, 01:22 PM   #2
Hobbletoe
Member
 
Registered: Sep 2004
Location: Dayton, Oh
Distribution: Linux Mint 10, Linux Mint 11
Posts: 148

Rep: Reputation: 18
I don't think you want grep ...

The grep command is usually used to pull the entire line out of a file. The sed command might be better for this as you can pull out just a specific part of the line. You could use grep to find the line in the file, then use sed to pull out the section that you want. I've been looking at it, but my sed skills aren't all that great.
 
Old 07-14-2006, 01:30 PM   #3
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
How about grep -o ?
Code:
grep -o "ted-1 " file.txt
 
Old 07-15-2006, 10:28 AM   #4
stevie_velvet
Member
 
Registered: Aug 2004
Location: Italia + UK
Distribution: RHEL 4 + Fedora FC5
Posts: 118

Original Poster
Rep: Reputation: 15
thanks both! i'll look up the -o option
it's to simple

both solutions search for the spcific occureence

grep -w "ted-1" file
grep "ted-1\b" file

i had the wrong regular expression
 
  


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
Regular expressions bhuwan Programming 5 02-25-2006 11:07 PM
regular expressions. stomach Linux - Software 1 02-10-2006 06:41 AM
Regular Expressions markjuggles Programming 2 05-05-2005 11:39 AM
help with REGULAR EXPRESSIONS ner Linux - General 23 10-31-2003 11:09 PM
Regular expressions aromes Linux - General 1 10-15-2003 12:29 PM


All times are GMT -5. The time now is 01:01 AM.

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