Results 1 to 3 of 3
Hi all,
Let's say a have 20 files in a directory. I want to copy 19 of them to another location.
How can I easily do this? Is there any ...
- 09-18-2005 #1Just Joined!
- Join Date
- Apr 2005
- Location
- Maputo, Mozambique, Africa
- Posts
- 19
Copy many files excluding a few of them using terminal
Hi all,
Let's say a have 20 files in a directory. I want to copy 19 of them to another location.
How can I easily do this? Is there any option to exclude files on the CP command?
- 09-18-2005 #2Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
You can do it if you pattern-match the names to exclude the unwanted one. Or try
which looks suitably cunning and obscure.Code:cp $(ls | grep -v unwantedfilename) dest_dir
- 09-18-2005 #3Just Joined!
- Join Date
- Apr 2005
- Location
- Maputo, Mozambique, Africa
- Posts
- 19
Hi,
It worked, but only for files without space char at the file name. When I try to escape the space chars, it give me an error.
Code:[amussa@cust29-10 rock]$ cp $(ls -b | grep -v METALLICA) ../testdir cp: invalid option -- \ Try `cp --help' for more information. [amussa@cust29-10 rock]$


Reply With Quote
