hi
when i am trying to check the file size using du command in shell script but getting a below error, although the file is present
du: cannot access `LOGS_18-08-20.tar.gz': No such file or directory
below is snippet of script
cd /home
dt=$(date --date="yesterday" +"%y-%m-%d")
du "LOGS_$dt.tar.gz"
Is LOGS_18-08-20.tar.gz
in /home
?
What do you get when you type
echo /home/LOGS_*.gz
Andrew
hi Andrew
yes file is in /home
this command o/p gives me
echo /home/LOGS_*.gz
I get
/home/LOGS_2018-08-20.tar.gz
The file is /home/LOGS_2018-08-20.tar.gz
and you are looking for /home/LOGS_18-08-20.tar.gz
. Change the %y
in your script to %Y
and try again.
Andrew
2 Likes