bash - remove date from filename but keep the file extension -



bash - remove date from filename but keep the file extension -

i have files these in directory called current_dir:

my data-file 2014-10.txt info file201409.txt

and want

my data-file.txt info file.txt

here tried

rename 's/ *[0-9]{4}-?[0-9]{2}.*$//' current_dir/*.txt

but removed .txt extension well.

i'm quite new linux, help me?

rename replaces matched part removing .*$ regular look keeps .txt

rename 's/ *[0-9]{4}-?[0-9]{2}//' current_dir/*.txt

examples

$ rename -n 's/ *[0-9]{4}-?[0-9]{2}//' *.txt rename(data file201409.txt, info file.txt) rename(my data-file 2014-10.txt, data-file.txt)

bash rename

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

ubuntu - Bash Script to Check That Files Are Being Created -