Home > other >  Finding files with specific range and moving the files
Finding files with specific range and moving the files

Time:12-15

I am trying to create a script to find files with naming convention as below:-

F_XYZ_1_2020.xml
F_XYZ_2_2020.xml
F_XYZ_3_2020.xml
F_XYZ_4_2020.xml
F_XYZ_5_2020.xml
....
F_XYZ_221_2020.xml

I am looking to create a script which finds all the files before F_XYZ_221_2020.xml and then move it to /destination/

I tried

ls -lrt | grep -v 'F_XYZ_221_' | mv * /destination/

It is not working for me.

CodePudding user response:

Try a range operator.

mv F_XYZ_{1..221}_2020.xml /destination/
  • Related