Reputation: 36
I want to list all the files in a folder excluding specific dates.
I tried using find
commend with ! -newermt
but it looks like its now working.
find /home/ubuntu/ -maxdepth 1 ! -newermt "2019-09-17" ! -newermt "2019-08-25" ! -newermt "2019-05-31" ! -newermt "2019-06-30" -type f
Ex: 1.txt created on 2019-09-18
2.txt created on 2019-09-17
3.txt created on 2019-05-19
4.txt created on 2019-01-20
I want to list all the files which are not created on 2019-09-18, 2019-01-20
I want the result should be,
2.txt created on 2019-09-17
3.txt created on 2019-05-19
Upvotes: 0
Views: 29
Reputation: 714
find
is inherently recursive, but you're specifying maxdepth of 1. You could use ls
:
ls -lah /home/ubuntu --time-style full-iso | awk '!/2019-01-20|2019-09-18/'
If you only want file names:
ls -lah /home/ubuntu --time-style full-iso | awk '!/2019-01-20|2019-09-18/' | awk 'BEGIN {ORS=""} {split($0,a," "); printf "%s\n",a[9]}'
Upvotes: 1