Fedora Linux Support Community & Resources Center
Old 24th July 2009, 09:52 PM
roddomi Offline
Registered User
Join Date: Jan 2008
Posts: 6
grep a space-separated list of string


How can I grep a space-separated list of strings from a file. For example, say I want to find the lines in file.txt that have the strings Monday or Tuesday in it.

LOOKFOR="Monday Tuesday"
grep $LOOKFOR file.txt (this doesn't work)

I tried using grep -F but it requires the list to be separated by newlines (not spaces).


Reply With Quote
Old 24th July 2009, 10:46 PM
scottro Offline
Retired Community Manager -- Banned from Texas by popular demand.
Join Date: Sep 2007
Location: NYC
Posts: 8,129
egrep -i "Monday|Tuesday" filename

Or LOOKFOR="Monday|Tuesday"

egrep -i $LOOKFOR filename

(The -i makes it case-insensitive)
Reply With Quote

grep, list, spaceseparated, string

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How-to realocate space from empty hard drive space to Fedora Core 5 partiton JoeyJoJoe Guides & Solutions (Not For Questions) 3 3rd February 2008 05:09 PM
server glx vendor string: SGI server glx version string: 1.2 akp Installation, Upgrades and Live Media 4 25th November 2007 08:04 PM
server glx vendor string: SGI, server glx version string: 1.2 + ATI X1950 akp Using Fedora 1 2nd September 2007 02:56 AM
sed regex string replacement after match string issue adosch Using Fedora 10 29th June 2007 04:07 PM
"grep" username in samba or grep file owner? overlord Servers & Networking 0 22nd July 2005 02:12 PM

Current GMT-time: 12:26 (Thursday, 21-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat