LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-21-2008, 12:02 PM   #1
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Rep: Reputation: Disabled
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)!"

Last edited by faizlo; 09-21-2008 at 12:04 PM.
 
Old 09-21-2008, 02:28 PM   #2
darkangel29
Member
 
Registered: Nov 2004
Location: Puerto Rico
Distribution: Ubuntu 10.04
Posts: 121

Rep: Reputation: 15
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.
 
Old 09-21-2008, 05:09 PM   #3
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Original Poster
Rep: Reputation: Disabled
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.

Last edited by faizlo; 09-21-2008 at 05:24 PM.
 
Old 09-21-2008, 05:59 PM   #4
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Or you could do it with rsync
rsync --exclude '*.exe' /source/dir/* /dest/dir/
 
Old 09-21-2008, 07:08 PM   #5
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Original Poster
Rep: Reputation: Disabled
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

Last edited by faizlo; 09-21-2008 at 07:09 PM.
 
Old 09-21-2008, 07:18 PM   #6
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Sorry -I normally use another option that implies recursion

Try

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

Note the trailing /'s
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying files YunaFF102 Linux - Newbie 4 07-21-2006 06:06 AM
copying files(s) in c climbingmerlin Programming 7 10-27-2005 03:00 PM
Copying FIles Casper12 General 4 08-07-2005 05:30 PM
copying files neozero62 Linux - Newbie 1 11-23-2003 06:38 PM
copying files Sol0 Linux - Software 7 08-18-2003 11:40 AM


All times are GMT -5. The time now is 03:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration