|
|
Welcome to the world of RegEx's
If the weird name throws you, "grep" is an acronym for "general regular expression
program". If that doesn't help, it's probably because you're wondering what a regular expression ("re" or "regex") is. Basically, it's a pattern used to describe a string of characters, and if you want to know aaaaaaall about them, I highly recommend reading Mastering Regular Expressions by Jeffrey Friedl and published by Unix über-publisher O'Reilly & Associates. Regexes (regices, regexen, ...the pluralization is a matter of debate) are an extremely
The key to this is understanding that certain characters are "metacharacters", which have
There are many of these metacharacters to keep in mind. Inside brackets ([]), a carat (^)
The period (.) matches any character at all, and the asterisk (*) matches zero or more times.
For details, try the man pages -- "man grep". There are a lot of different versions of the
Confusing? Maybe, but regular expressions aren't that bad when you get used to them, and
Let's say you have an website stored on your computer as a series of html documents.
grep -ir ']*(face="sans-serif"|size="12")' *.htm *.html This does a number of things. The -i tells grep to ignore case (otherwise it's case sensitive,
The next question is, what do you want to do with this information you've come up with?
grep -irl ']*(face="sans-serif"|size="12")' *.htm *.html >font_files.txt Great. But we can do better still. If you are comforable with the vi editor, you can call vi
vi `grep -ir ']*(face="sans-serif"|size="12")' *.htm *.html` The result of this command, as far as your tcsh shell is concerned, is something along the lines
vi index.html about.html contact.html music.html...... etc. The beautiful thing here is that if you quit vi & re-run the command later, it will be
And if you want to get really ambitious, you can use these techniques in ways that
|
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.08 seconds |
|