I want to copy many files inside a single directory. An example filename starts with error042021.mysite and I want the new name end with -dev.co.at.txt. I think I need a wildcard for the number, because the numbers will differ: 022021, 032021, 042021, etc. (number= Month, Year).
For example this is what I want to do with error042021.mysite.at.txt:
cp -p error042021.mysite.at.txt error042021.mysite-dev.co.at.txt
I don't wan't to use mv because the old file should still remain.
I tried:
FILE=/srv/www/mysite.at/storage/logs/error/error??????.mysite.at.txt
if [[ -f "$FILE" ]]; then
echo "$FILE exists."
cp -p error??????.mysite.at.txt error??????.mysite-dev.co.at.txt
fi
Or is it better to use sed?