Xref: utzoo comp.unix.questions:29486 comp.unix.shell:1690 Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uwm.edu!bionet!agate!ucbvax!unisoft!fai!sequent!lugnut From: lugnut@sequent.UUCP (Don Bolton) Newsgroups: comp.unix.questions,comp.unix.shell Subject: Re: Awk with passed parameters Keywords: awk bsd shell Message-ID: <55345@sequent.UUCP> Date: 14 Mar 91 22:18:14 GMT References: <3022@dsacg3.dsac.dla.mil> <1991Mar10.033553.28978@pilikia.pegasus.com> Reply-To: lugnut@sequent.UUCP (Don Bolton) Organization: Sequent Computer Systems, Inc Lines: 39 In article <1991Mar10.033553.28978@pilikia.pegasus.com> art@pilikia.pegasus.com (Art Neilson) writes: >In article <3022@dsacg3.dsac.dla.mil> nfs1675@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