1

I have to find all files whose name start with String + Number like below

ABC123_filedemo.txt

AB_451_filetxt

CD_789_demo.txt

demo_files_FD123.txt

d_files_re_SD_456.txt

I have tried this Command But Not working

export _date=`date "+%d_%m_%Y_%H_%M_%S"`
find . -type f -iname  'AB*'  -exec mv {} /Demo_files"_"$_date \;
gopsutelmu
  • 11
  • 1

2 Answers2

1

Is ".txt" relevant? Then try:

find  ./  -regextype posix-extended -regex '.*[a-zA-Z]+.*[0-9]+\.txt' -exec <your stuff>

inspired by: https://stackoverflow.com/a/5249797/10514446

1

This looks like a simple example:

find ./ -name "[a-zA-Z]*[0-9]*"

Every file here needs to start with a letter 'a'-'z' (small or large caps) and somewhere in the filename you need a digit [0-9].

Dominique
  • 16,450
  • 15
  • 56
  • 112