I have a backup script which is creating two files:
a) db_mywebsite_2018-01-10_00-25.sql.gz
(150 MB)
b) mywebsite1_2018-01-10_00-01.tar.gz
(2 GB)
I want to remove the date (XXXX-XX-XX_XX-XX) from file names. Because the backup is made daily, each file will have a different date in the name. For this, I'm using the following command:
rename -v -n 's/_\d{4}-\d{2}-\d{2}_\d{2}-\d{2}//' *.sql.gz
For testing, I have touch
ed two files db_mywebsite_2018-01-10_00-25.sql.gz
and mywebsite1_2018-01-10_00-01.tar.gz
Command:
rename -v -n 's/_\d{4}-\d{2}-\d{2}_\d{2}-\d{2}//' *.sql.gz
Output:
db_mywebsite_2018-01-10_00-25.sql.gz renamed as db_mywebsite.sql.gz
1. The problem is that despite the above message "db_mywebsite_2018-01-10_00-25.sql.gz renamed as db_mywebsite.sql.gz" when I check it via ls -l
it looks like that file name hasn't been renamed.
2. Rename command (regex) is not working on file mywebsite1_2018-01-10_00-01.tar.gz
.