Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copy files across directories using terminal in mac

Tags:

shell

macos

How to copy all files with an specific extension .SAV from one directory (including all subdirectories within that directory) to another one? I am using the terminal from mac. I have tried

    /Users/tournillon/my_directory/research_projects/dissertation_related/inequality
    Antonio-P-Tournillon-Ramoss-iMac:inequality tournillon$ ls
    Brazil              dhs_dados           imr201101app.pdf
    GHME_Education_final.pptx   dhs_sav_files
    Antonio-P-Tournillon-Ramoss-iMac:inequality tournillon$ dhs_dados /*.SAV/ dhs_sav_files/ 

I would assume this is a trivial task but I just can't get the syntax right.

Many thanks,

Antonio Pedro.

like image 685
Tom Avatar asked Dec 04 '22 03:12

Tom


2 Answers

find /source/directory -iname \*.sav -exec cp {} /destination/directory/ \;

like image 128
njahnke Avatar answered Dec 26 '22 16:12

njahnke


If you mean a UNIX copy,

cp -R <dirA>/*.sav <dirB>/

I'm not sure what dhs_dados is in your question..

like image 20
Justin Jasmann Avatar answered Dec 26 '22 16:12

Justin Jasmann