Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 07-14-2006, 01:54 PM   #1
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, 02:22 PM   #2
Registered: Sep 2004
Location: Dayton, Oh
Distribution: Linux Mint 17
Posts: 150

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, 02:30 PM   #3
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
How about grep -o ?
grep -o "ted-1 " file.txt
Old 07-15-2006, 11:28 AM   #4
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


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

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration