For example using C shell I want
to edit a handful of files that
contain the string "ProcessInput"
in my current directory.
Step 1:
Find the files which uses "ProcessInput"
% grep "ProcessInput" *.c
a.c:ProcessInput ( int a )
b.c:Description : ProcessInput is used to process the input
given by the user
b.c:Call ProcessInput to perform ...
c.c:val = ProcessInput(2) ;
c.c:val = ProcessInput(3) ;
Step 2:
Extract the filenames on the left.
$!! | awk -F: '{print $1}'
a.c
b.c
b.c
c.c
c.c
step 3:
Remove the duplicates
!! | sort -u
Step 4:
Now edit it !
vi `!!`
which runs vi `grep "ProcessInput" *.c | awk -F: '{print $1}'
| sort -u`
This tip generously supported by: desikann@future.futsoft.com
NOTE: All tips provided are USE AT YOUR OWN RISK. Tips are submitted
by various unix admins around the globe. UGU suggest you read and
test each tip in a non-volitile environment before placing into
production.