It is necessary to move from directory A to directory B files with more than three digits in the title. Bash script code:

#!/bin/bash mv ./cat1/* cat2 

This code allows you to move files from directory 1 to directory 2, but how to add a regular expression to this code, I tried everything in grep, but nothing comes out. Maybe someone knows?

  • 3
    I would try somewhere like this mv ./cat1/*[0-9]*[0-9]*[0-9]*[0-9]* cat2 mv ./cat1/*[0-9]*[0-9]*[0-9]*[0-9]* cat2 - KoVadim
  • thank. Works - Vadim Moroz

1 answer 1

Something like this mv ./cat1/*[0-9]*[0-9]*[0-9]*[0-9]* cat2 How it works - we look for files in which there are some characters ( * ), then the number [0-9] ) and so on until the desired number of characters. The asterisk can correspond to both the absence of the characters and the numbers. Since 4 digits are clearly written, it will select files with at least 4 digits (that is, more than 3 digits).