[Techtalk] copying similar files in one command

aec brat at magma.ca
Tue Nov 2 08:10:17 EST 2004


> On Sun, 31 Oct 2004 05:21:38 -0600, percila orphan
> <millward at ms.umanitoba.ca> wrote:
> > I need help with the cp command.
> > Sometimes I'm have to copy a lot of files that
> > have something in thier names in common.
> > For example, if they all have the word "ed" in them.
> > /home/ed/ ls -l | grep "ed"  displays all the files with the word
> > "ed" in them within that directory /home/ed/
> > I want to copy those files to the directory  /usr/temp
> > Can I copy them all with one command? What might
> > that be?
> > As it is now, I'd have to spend 10 or more minutes typeing
> > away like a fiend to get it done. Any suggestions would
> > be welcome!
> 

Hi, all the other responses should handle the task you originally 
posted about however I would strongly recommend until  your comfortable
with using the shell that you add -i to any copy or move command,
this will force the shell to prompt you if it encounters a file 
or directory  of the same name.

It is common to have this in your ~/.bashrc  :

# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'


-- 
Angelina Carlton


More information about the Techtalk mailing list