LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   copying files of cert (https://www.linuxquestions.org/questions/linux-newbie-8/copying-files-of-cert-671383/)

faizlo 09-21-2008 11:02 AM

copying files of cert
 
Peace,

Here is a quick question which I will really appreciate it.

I want to copy files and folders (keeping the same hierarchy) from a certain machine to another. The point is I do not want to copy files of certain extension, like say foo.exe (and it is one extension that I do not need) from the original machine to the new one. How may one do this?


Faizlo

PS.
I could not edit the title of the post, sorry for the typo. I wanted to say "copying files of certain type(s)!"

darkangel29 09-21-2008 01:28 PM

Code:

ls -1 | grep -v "^.exe$" | xargs -n 1 -iHERE cp -R HERE <destination
Where 'ls -1' gets all the contents of the directory, grep removes entries of ".exe", and then xargs copies everything left.

faizlo 09-21-2008 04:09 PM

Peace,

Thank you darkangel29, I have some questions:

What is "HERE"?
When I tried ls -1 alone, it did not give me a recursive listing of all subdirectories. I read the man pages and I found -R flag, should I use this?

faizlo

PS.

I used the following command:
ls -1 | grep -v "^.exe$\" | xargs -n 1 -i cp -R < /my_destination/faizlo/tutorials/ (I removed HERE) I was given the error:
Illegal variable name.

billymayday 09-21-2008 04:59 PM

Or you could do it with rsync
rsync --exclude '*.exe' /source/dir/* /dest/dir/

faizlo 09-21-2008 06:08 PM

Hi billymayday,

rsync did not go through all the subfolders. Is there a way to do this (keeping the same hierarchy as in the original source directory?

faizlo

billymayday 09-21-2008 06:18 PM

Sorry -I normally use another option that implies recursion

Try

rsync -r --exclude '*.exe' /source/dir/ /dest/dir/

Note the trailing /'s


All times are GMT -5. The time now is 07:31 AM.