DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


NAVIGATION
Home
Store
INSIDE MAC
Television Shows
Broadcast Shows
Daily News Shows
Special Shows
EVENTS
DAILY TIPS
Design
Mac OS X
Mac OS X UNIX
COMMUNITY
Forums
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS

OSXFAQ Mac OS X UNIX Tip-of-the-Day   back to index

Week 101 - Unix Commands Reference (7 March 2005)

by Adrian Mayo - Editor, OSXFAQ

Thursday - Commands to Search for Content

grep ... search a file for text
Search a file for specific text, or a pattern specified by a regular expression (see 'man re_format')
Option -i to specify case-insensitivity
Option -w to match whole words
Option -r to search all files in a directory subtree
Option -v to display lines that do NOT match
Options -n, -l, -L, -h, -H to control the what is printed in terms of matched text, filenames, and line numbers
Option -E to use extended regular expressions instead of basic
Option -F to use fixed strings (this is much quicker than pattern matching)

egrep ... search a file for text
The same as 'grep -E', i.e it used extended regular expressions

fgrep ... search a file for text
The same as 'grep -F'

(See tips weeks 9 and 10)

zgrep, bzgrep ... grep a zipped, bzipped file

bzegrep ... egrep a bzipped file

bzfgrep ... fgrep a bzipped file

perl ... a text manipulation language
From the man pages:
Perl is a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information. It's also a good language for many system management tasks. The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal).


Discuss this trick in the Learning Center forum


If you want to learn more about Mac OS X Unix visit the Learning Center  click.

  • For beginners: Mac OS X Unix Tutorials
  • For detailed information on specific topics: Advanced Unix
  • For OS X in gereral: Mac OS X Tutorials

Copyright © 2000-2008 Inside Mac Media, Inc. All rights reserved.
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users.
Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc.