LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-11-2002, 02:36 PM   #1
granny
Member
 
Registered: Nov 2002
Distribution: RH
Posts: 141

Rep: Reputation: 15
should be an easy ?


What is the or operator in linux? For example I know ^ usually signifies beginning, $ end, but what would I specify as an or operator. I am putting this in a grep string. This is what I have so far... I want to take all commands from /usr/bin that begin with the letter m or t into a text file called cmd.txt

ls /usr/bin | grep ^m > cmd.txt

but what would I use to do begins with m or t? Thanks all.
 
Old 12-11-2002, 02:46 PM   #2
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 48
grep ^[mt]
 
Old 12-11-2002, 02:51 PM   #3
granny
Member
 
Registered: Nov 2002
Distribution: RH
Posts: 141

Original Poster
Rep: Reputation: 15
Son of a b! I was so close, I had tried

grep [^mt]
grep [^m^t]
grep ^m^t
grep [^m] [^t]

Soot, I think thats the only one I didn't try! Thanks a bunch moses, you are my savior. (Judging by that you'd think I'm religeous It worked perfectly!
 
Old 12-11-2002, 02:56 PM   #4
granny
Member
 
Registered: Nov 2002
Distribution: RH
Posts: 141

Original Poster
Rep: Reputation: 15
ok how would I also add to the string the same thing but have it so it also outputs all commands that end in r to the same file

so...

ls /usr/bin | grep ^[mt] > cmd.txt

what needs to be added tried

ls /usr/bin | grep ^[mt] r$ > cmd.txt
ls /usr/bin | grep ^[mt] [r$] > cmd.txt

I know these ?'s seem acenine, but I am trying to learn everything as in depth as possible, and really appreciate the help!
 
Old 12-11-2002, 04:55 PM   #5
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 48
There may be a better way, but this works:

ls /usr/bin | grep ^[mt] | grep r$ > cmd.txt
 
Old 12-11-2002, 07:05 PM   #6
granny
Member
 
Registered: Nov 2002
Distribution: RH
Posts: 141

Original Poster
Rep: Reputation: 15
thanks moses

thanks buddy! I will just call you Master from now on

Wow multiple pipes. Intense!
 
Old 12-12-2002, 12:59 AM   #7
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 48
No, just moses. ;)
MasterC could be called master, though.
 
  


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
easy connect not easy in suse greg collins Linux - Newbie 11 03-30-2006 08:31 PM
Easy urpmi ,no easy send mail. akihandyman Linux - General 2 12-27-2004 03:15 PM
Linux4RegularGuys - EASY FTP setup using vsftpd - READ THIS FOR EASY HELP DropHit Linux - Networking 4 11-25-2004 03:44 PM
Easy for most ... Please help.... kaz4u2dig Linux - Newbie 1 10-18-2004 10:46 PM
Here's an easy one... jhotchkiss Linux - Software 5 09-23-2003 12:53 PM


All times are GMT -5. The time now is 03:55 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration