Your Ad Here

Selasa, 27 November 2012

Unix Tip: FINDING A STRING

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3580 - November 27, 2012

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


FINDING A STRING

How to find a string somewhere on the system. Many times we are
called to search for a string, but we have no idea where it may
be lurking. Judicious use of the find and grep commands will
make you a hero with your co-workers.

# find . -type f -exec grep "string or options" /dev/null {} \;

Normally using only:
# find . -type f -exec grep "string/options" {} \;

Produces the target string, but you will have no clue as to where
it is located, making this almost as frustrating as using windoze!
Remember when grep'ing against multiple files the filename will be
listed before the match.

$ grep there *
foo:I found the target here
bar:You are there

In our find command we use /dev/null as a file to search against, since
we know the search will always fail if the string is found in "{}" there
filename is printed. To borrow from a famous quote:
"Pretty tricky sis!"

This tip generously supported by: james_b_horwath@glic.com


--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Tidak ada komentar:

Posting Komentar

Your Ad Here
Free Automatic Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink