ls -l on a directory and grep for a variable

I want to find all entries in a directory for a given date, and write those entries to a file.

#!/bin/ksh
d=`date '+ %b %e'`   # -- this works e.g. Aug 1
files=`/usr/bin/ls -l|grep '$d' ` # -- the pipe doesnt work, but the ls -l does.
 

What do i need to do to be able to send the list of files to '> an_output.dat'

the shell will not substitute $d when masked with '', use ""

1 Like

:slight_smile:
Thanks! I also added the echo "$files" to capture the output in a flat file. Very much appreciate it.