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?

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.

  • What about files like saturnism.dat ? – Gilles Quenot Nov 17 '14 at 17:03
  • @sputnick thanks, edited answer with a ^ – mkc Nov 17 '14 at 17:05
  • What about LANG ? My term is in french, your solution will never works – Gilles Quenot Nov 17 '14 at 17:09
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)]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.