1

While doing this using below command

find /tmp type -f ls|grep "Any date"|wc -l

*Any date =May 15 or May 5

it gives the correct result for May 15 but for May 5 it does not give any result because in ls command there is extra space prior to 5 th may.

How to resolve these space issue so that my script work for both the values?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

1 Answers1

1

Search for month followed by 1 or more spaces. e.g.

find . -type f -ls | grep -E "May +5"

A more elegant approach (and to avoid the don't parse ls pitfalls) would be to use

find . -type f -newermt 2018-05-05 ! -newermt 2018-05-06 | wc -l
steve
  • 21,892