Awk with passed parameters

Don Bolton lugnut at sequent.UUCP
Fri Mar 15 08:18:14 AEST 1991


In article <1991Mar10.033553.28978 at pilikia.pegasus.com> art at pilikia.pegasus.com (Art Neilson) writes:
>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 }
>'

I may be missing something obvious here but why use awk at all?

IFS=': '
set `date`
hrs=$4
m=$2   

etc

works just fine for a 12 hour clock display I use from the date output


Don "1600 hrs reminds me of people with bad haircuts and boots" Bolton



More information about the Comp.unix.questions mailing list