Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex for moving based on last 4 digit combinations in a file

I have files which are labelled in the following manner, and need to move them according to 0000 – 0010 (base the last 4 digits. What is the regex for this?
I have tried this regex but I don’t get anything. As someone who isn’t an expert on regex any help would be appreciated.

find ./ -regextype egrep -regex '.*file([0-9]\+-[0-9]\+-[0-9])\+.flac'

I get no output from my regex, but would like to copy only 0000 to 0010 to a new location

1241-137614-0000.flac
1241-137614-0001.flac
1241-137614-0002.flac
1241-137614-0003.flac
1241-137614-0004.flac
1241-137614-0005.flac
1241-137614-0006.flac
1241-137614-0007.flac
1241-137614-0008.flac
1241-137614-0009.flac
1241-137614-0010.flac

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I suggest with bash version >= 4.0:

mv 1241-137614-{0000..0010}.flac <destionation_dir>

If a source file does not exist, you will get an error message from mv.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading