[olug] Unix Tip: ONE STEP AT A TIME WITH !!

Unix Guru Universe listserv at ugu.com
Wed Jul 16 16:32:03 UTC 2003


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

			      UNIX GURU UNIVERSE 
			         UNIX HOT TIP

			Unix Tip 2023 - July 16, 2003

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

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


ONE STEP AT A TIME WITH !!

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 at future.futsoft.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 at ugu.com - Copyright 1994-2001
==========================================================================



More information about the OLUG mailing list