2

I am not sure if it is possible.

I do ls -l, it gives all the files in the current directory. Is there a way to say list only files that weren't created/modified on Saturday's with shell command?

3 Answers3

1

A way to do this :

$ LANG=C find . -maxdepth 1 -printf '%p %AA\n' |
    awk '$NF=="Saturday"{next}{$NF=""}1'

I assume we don't print files for all Saturdays. This is or not what you expect.

1

Simpler:

find . -maxdepth 1 -printf '%Ta\t%p\n' | grep -v -i '^sat'

ref: This answer.

Ketan
  • 9,226
1

You should select which time you need

  • %y modification
  • %w creation
  • %z change

or any combination:

stat * --printf="%n\t%y %z\n" | grep -vF $(date -d "last Saturday" +%F) | cut -f1

Also choice what infomation you need and compose --printf= line.

Or you can use just find command

find -maxdepth 1 -type f -daystart \
     ! -mtime $[$(date +%d)-$(date -d "last Saturday" +%d)]
Costas
  • 14,916