I want to delete all directories apart from the current date's directory. directory names are taken as date in this MM-DD-YY format so directory name is
10-12-17
10-11-17
10-10-17 ..etc
#!/bin/bash
echo Hello World!
one_day=$(date -d "1 days ago" +%m%d%y)
for f in [0-9][0-9]-[0-9][0-9]-[0-9][0-9]; do
[ -d "$f" ] || continue
(( $f < $one_day )) && sudo rm -rf "$f"
done
While running my script I am getting the following error:
./script.sh: line 9: ((: 10-08: value too great for base (error token is "08")
./script.sh: line 9: ((: 10-09: value too great for base (error token is "09")