UNIX GURU UNIVERSE
UNIX HOT TIP
Unix Tip 3149 - September 20, 2009
http://www.ugu.com/sui/ugu/show?tip.today
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
SEARCH AND EDIT IN ONE
Want to search all files for in the local directory for a string and then edit them in vi?
This will do it.
vi `grep -il "target" *.sql 2>/dev/null`
Search all files in a directory structure for a regular expression and edit with vi.
vi `find . -type f -name "*.sql" -print | (xargs grep -il "[a-z][a-z]*get" 2>/dev/null)`
It's a good idea to redirect stderr in case you come across files for which you don't have read permissions. The errors messages would be passed as arguments to vi.
This tip generously supported by: jkstill@bcbso.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