Awk with passed parameters

Art Neilson art at pilikia.pegasus.com
Sun Mar 10 13:35:53 AEST 1991


In article <3022 at dsacg3.dsac.dla.mil> nfs1675 at dsacg3.dsac.dla.mil ( Michael S Figg) writes:
>
>
>I'm trying to write a short shell script using awk to list files in the
>current directory that have todays' date on them. It seems like something
>like this should work, but I haven't had any luck:
>
>set d = `date`
>ls -l | awk '$5 == x && $6 == y  {print}' x=$d[2] y=$d[3]

Here's my solution using the Bourne shell and standard awk.

:

date="`date`"
set $date

ls -l | awk '
BEGIN {
	mm = '\"$2\"'
	dd = '\"$3\"' + 0
}
	$6 == mm && $7 == dd { print }
'
-- 
Arthur W. Neilson III		| INET: art at pilikia.pegasus.com
Bank of Hawaii Tech Support	| UUCP: uunet!ucsd!nosc!pilikia!art



More information about the Comp.unix.shell mailing list