I have a directory like 20170811.There are many files in this directory.I want to record count of all the files with date of previous day.Means, when i ran this script it will show record count according to Today-1I want to print only previous date and record count.ThanksAman
Shell scripting, print all the record count from the file with one day back data
shell script;files;date
Use find command and add date formatting pattern to find's path parameter via command substitution. find /path/to/$(date -d '-1day' '+%Y%m%d') -type f -exec wc -l '{}' +If your files also have included date formatting pattern same as directories you can add in -name parameters:find /path/to/$(date -d '-1day' '+%Y%m%d') -type f \    -name *$(date -d '-1day' '+%Y%m%d')* -exec wc -l '{}' +Note that asterisks in *$(..)* around command substitution used for any files matched with date pattern containing in its name.The '+%Y%m%d' parts is printing date in pattern YYYYMMDD, you can change it to any pattern you would like per your files/directories name.like '+%Y-%m%-d', is printing in YYYY-MM-DD, even you can add time formatting pattern with printing its pattern as well.date -d '-1day' '+%Y-%m-%d %H:%M:%S'  # will print 2017-08-13 11:19:49