2
rated 0 times
[
2]
[
0]
/ answers: 1 / hits: 624
/ 2 Years ago, mon, may 9, 2022, 7:27:26
I'm trying to rename every access.log.gz
file (note: exact filename, not "beginning with" or "containing") found in /home/*/logs
to date-access.log.gz
in the same folder.
for file in /home/*/logs/access.log.gz
do
mv -v "$file" /home/*/logs/old/`date +%G-%m-%d`"-access.log.gz"
done
Of course I'm getting /home/*/logs/2014-09-08-access.log.gz - No such file or directory
. How can I call the *
paths back? Each file should be renamed and moved to /old/ subdir of the source folder. I tried with
mv -v "$file" /home/`$1`/logs/old/`date +%G-%m-%d`"-access.log.gz"
... but didn't work.
More From » bash