Score:1

how to exclude folders by date with find?

ng flag

This is "myfolder":

tree -a 'myfolder'
myfolder
├── 20220902
│   ├── filefoo
│   └── filebar
├── 20221001
│   ├── filefoo
│   └── filebar
└── 20221015
    ├── filefoo
    ├── filebar
    └── filexyz
  etc...

my command:

find $folder/$(date +"%Y%m"*) -type f | xargs -I {} awk '/^total:/{sub(".*/", "", FILENAME); print FILENAME" "$NF}' {})

Problem: i need exclude weekends. How do I do it?

PD: I know that in bash/awk it is

%u The weekday as a decimal number (1–7). Monday is day one.

thanks

Update Solved!

I found the answer in stackoverflow HERE

Score:1
sb flag

To filter out the weekends, you could format the name of the folder to a date format %u, which signifies the day of the week (by number).

Check out this example:

FOLDER_DATE=$(date -d '20221014' +%u)   #your folder name would go here

if [[ "$FOLDER_DATE" -eq 6 || "$FOLDER_DATE" -eq 7 ]]
then 
  echo "Weekend"
else 
  echo "Not Weekend"
fi
acgbox avatar
ng flag
Even though your script didn't help me with "find", it did help me a lot with a variant of the same thing. thanks
jabbson avatar
sb flag
Yes, in this example I only focused on the differentiation between the weekend folders and non-weekend folders.
acgbox avatar
ng flag
Thank you very much. To be more specific, it helped me with this script, which also serves the same purpose as this question: https://serverfault.com/a/1112011/480349
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.