I have a rename command as follows:
rename ".csv" "-en.csv" Daily_vills.csv
rename "^" "07302019" Daily*
when i run this, i get an error "rename: invalid option -- 'e'". I already tried "\-en.csv", but this results in "Daily_vills\-en.csv"
my question is how to make bash understand that -en is a replacement value and not a parameter.
original:
Daily_vills.csv
Target;
07302019Daily_vills-en.csv
Any help on this is greatly appreciated
Use -- to notify rename of end of options.
rename -- ".csv" "-en.csv" Daily_vills.csv
From posix utility conventions:
Guideline 10:
The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.
It is common in many *nix tools to notify with -- the end of options. Examples:
# touch a file named -a
touch -- -a
# cat a file named -a
cat -- -a
# printf the string -b
printf -- -b
# find a string '-c' in files in current directory
grep -- -c *
The rename utility also follows the guideline from posix utility conventions. The -- may be used to notify rename of the end of options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With