Copy all except one file?

Peter Garrett peter.garrett at optusnet.com.au
Sat Jul 29 14:07:22 UTC 2006


On Sat, 29 Jul 2006 19:50:08 +0800 (CST)
Soo Qing <sooqing at yahoo.com.sg> wrote:

> Hi!
> 
> I often need to copy all files (*) except one file
> (example.txt) from one directory to some places. How
> do I do that from the terminal?
> 
This appears to do the job:

$ cp $(ls | grep -v *.txt) /path/to/destination-for-copied-files

For instance:
peter at prospero:~/test $ touch foo.blah bar.foo bleh.txt
peter at prospero:~/test $ ls
bar.foo  bleh.txt  foo.blah

 $ cp $(ls | grep -v *.txt) ~/copy/
peter at prospero:~/test $ ls ~/copy
bar.foo  foo.blah

I'm sure there are other ways, but that's what came to mind :)

Peter


> 
> 		
> ____________________________________________________
> Yahoo! Singapore Answers
> Real people. Real questions. Real answers. Share what you know at http://answers.yahoo.com.sg
> 
> -- 
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users




More information about the ubuntu-users mailing list