How can I rename a file in linux to strip out certain characters from the file name?
For example,
My123File.txt to be renamed to My123.txt
If you're okay with just wildcards (not full regexes), then you might try something like
f='My123File.txt'
mv $f ${f/File/}
This type of shell expansion is documented here.
If you really need regexes, try
f='My123File.txt'
mv $f $(echo $f | sed -e 's/File//')
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