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`
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment