0

I've build this little script for finding files which was modified in a specified month.

My script worked fine for this last four years, but from a recent update, now with bash V4, this won't work anymore and I don't understand why.

There is the script (fmonth.sh):

#!/bin/sh

month=$1
shift

printf "now\n%s-01\n%s-01 00:00 +1 month\n" $month $month |
    date -f - +%s |
    xargs printf "n=%s/60-.5;s=%s/60;e=%s/60;n-s;if (n-e <0) 0 else n-e\n" |
    bc -l |
    xargs printf "find $@ -mmin -%.0f -mmin +%.0f -print0\n" |
    sh |
    xargs -0 /bin/ls -ltrd |
    less -S

And this could by used as following:

fmonth.sh 2012-09 /etc /home/user /root /var/lib
techno
  • 525
  • 3
  • 13

1 Answers1

0

Ok, I found the answer: $@ could be replaced by $*:

#!/bin/sh

month=$1
shift

printf "now\n%s-01\n%s-01 00:00 +1 month\n" $month $month |
    date -f - +%s |
    xargs printf "n=%s/60-.5;s=%s/60;e=%s/60;n-s;if (n-e <0) 0 else n-e\n" |
    bc -l |
    xargs printf "find $* -mmin -%.0f -mmin +%.0f -print0\n" |
    sh |
    xargs -0 /bin/ls -ltrd |
    less -S

This work fine now!

I'm not sure to really understand why... for now... I would search for the reason later...

techno
  • 525
  • 3
  • 13