I have millions of files with the following nomenclature on a Linux machine:
The first 10 digits are timestamp and the ones followed by a
_ are specific ids. I want to move all the files matching specific filename ids to a different folder.
I tried this on the directory with files
find . -maxdepth 1 -type f | ??????????_a1ac*.jpg |xargs mv -t "/home/ubuntu/ntest"
However I am getting an error indicating:
bash 1559704165_a1ac6f55fef555ee.jpg: command not found
When I tried,
mv ??????????_a1ac*.jpg I am getting argument list too long error. I have atleast 15 different filename patterns. How do I move them.
| ??????????_a1ac*.jpg: bash expands it to several filename, the first being
1559704165_a1ac6f55fef555ee.jpg, si you end up, in that 2nd pipe stage, trying to execute:
1559704165_a1ac6f55fef555ee.jpg next_matching_filename 3rd_matching_filename ... nth_matching_filename. I guess you tried instead to filter to that filename (see answers below for that)