1

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

1 Answer 1

1

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
3
  • Even though your script didn't help me with "find", it did help me a lot with a variant of the same thing. thanks
    – acgbox
    Commented Oct 17, 2022 at 13:46
  • Yes, in this example I only focused on the differentiation between the weekend folders and non-weekend folders.
    – jabbson
    Commented Oct 17, 2022 at 15:37
  • Thank you very much. To be more specific, it helped me with this script, which also serves the same purpose as this question: serverfault.com/a/1112011/480349
    – acgbox
    Commented Oct 18, 2022 at 13:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .