bash - IF clause construction over awk command in UNIX -
i need run ls -l command , extract modification date of files. then, compare actual date, and, if not equal (ie. file hadn´t been updated on current day), extract filename file. here got far:
data1=`date | awk '{print $2}'` data2=`date | awk '{print $3}'` ls -l <file_path> | awk '{ if ( $data1 != $6 && $data2 -ne $7 ); echo "founded" }' | wc -l
i´ve extracted month , day current date, compared month , day list command, , i'm doing word count check number of files hadn´t been updated, before add redirecting command filenames new file.
the problem if clause isn´t processing way should.
notes:
- $6 month, it´s string
- $7 day of month, it´s numerical char
- i´m using red hat 5.8 bash
as noted in comments, give files more 24 hours old:
find pattern -type f -mtime +1
this older midnight local time if you'd prefer full day of age:
find pattern -type f -mmin +$(($(date +"%h*60+%m")))
Comments
Post a Comment