I have read this Copying multiple specific files from one folder to another which could not help me.

I have thousands of files in /Users/Marine/Desktop/folderGN, some of which I want to keep and some of which I want to move.

There are several files with different names and I want to move only those that have a name containing Protein or MSMS or PSms.

I want to move them from




To glob for the different names, you can use a for loop like so

for f in /Users/Marine/Descktop/folderGN/{*[Pp]rotein*,*MSMS*,*PSms*}; do echo mv -v -- "$f" /Users/Marine/Descktop/myfolder ; done

Remove the echo after testing to actually move the files.

I have copied your paths exactly (including the possible typo in Descktop?), but you could instead do this with relative paths:

cd /Users/Marine/Descktop/folderGN
for f in *[Pp]rotein* *MSMS* *PSms* ; do echo mv -v -- "$f" ../myfolder ; done 

(remove echo after testing as before)

  • thank you so much. I cannot like it too but it solved my problem. I have one more question which I will ask soon Dec 7 '16 at 10:25
  • @LearnerAlgorithm you're welcome :D
    – Zanna
    Dec 7 '16 at 10:32
  • I asked another question, I would appreciate if you could help me there too askubuntu.com/questions/857999/… Dec 7 '16 at 10:56

This is in fact very simple. If you want files with a certain letters/numbers in their name, and anywhere in the name, to be moved to some directory, just:

move *some_name* directory

This is as simple as:

mv /Users/Marine/Descktop/folderGN/*protein* /Users/Marine/Descktop/myfolder/

mv /Users/Marine/Descktop/folderGN/*PSms* /Users/Marine/Descktop/myfolder/

mv /Users/Marine/Descktop/folderGN/*MSMS* /Users/Marine/Descktop/myfolder/

This command is case sensitive. Notice that Descktop should most probably be Desktop, and that Users/Marine is more like a Mac setup, not a Ubuntu one.


In a terminal window use the usual mv command: mv /Users/Marine/Descktop/folderGN/*MSMS* /Users/Marine/Descktop/myfolder

repeat for other names (i.e. PSms, etc.) respectively.

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.