2

I have a folder that contains 1208 folder. In each of these folders, I have 6 different files which follows a special naming criteria.

What I need to do is to get only one of these files from all the 1208 folders if it contains the following in its name: _fa_a

The hard way is to go into each of the folders and copy that file to my destination folder.

Is there an easier way to do so? or I need to do it manually?

2
find your_folder -type f -name "*_fa_a*" | while read filename; do echo mv "${filename}" destination_folder; done

this find command finds the file and move to the destination_folder.

i added echo command for you to verify the results before move it. once you are happy with echo command output, remove the mv command.

  • 1
    Why not use -exec option of find instead of piping to a loop ? – Valentin B. Jan 13 '17 at 10:06
  • 1
    As in find ...... -exec echo mv {} destination_folder \; – Valentin B. Jan 13 '17 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.