[K12OSN] OT: bash help - copying a series of files

Rob Owens rob.owens at biochemfluidics.com
Fri Dec 12 13:11:00 UTC 2008


No, I don't want to copy all the files in that directory, or even a
particular pattern of files (*.desktop).

-Rob

Garrett Novotny wrote:
> Rob,
> 
> Are you trying to do all the files in that specific directory?  If so you would use a wildcard (*) or like in your example *desktop to get any files ending in desktop
> 
> example: cp /usr/local/share/icons/*.desktop /destination/folder
> 
> If you are dealing with coping folders and files folders I think you need to use the -R (recursive) switch/option...
> 
> example: you have a 10 files and 5 folders inside the folders there are also a number of files to copy all of them you could use...
> 
> cp -R /locationOfFolderAndFiles/* /destination/
> 
> Hope this helps,
> Garrett
> 
> 
> 
> --
> Garrett Novotny
> Technician - Technology Services
> Middleton-Cross Plains Area School District
> 7106 South Avenue - Middleton, WI 53562
> [email]  gnovotny at mcpasd.k12.wi.us 
> [http] www.mcpasd.k12.wi.us
> [voice]   608.829.9036 - Help Desk
> 
> 
> 
> 
>>>> Nils Breunese <nils at breun.nl> 12/11/08 2:37 PM >>> 
> Rob Owens wrote:
> 
>> j.w. thomas wrote:
>>> Rob Owens wrote:
>>>> I've read this somewhere before, but I'm having trouble finding it  
>>>> on
>>>> google...
>>>>
>>>> I need to copy a series of files without using a loop.  I think the
>>>> syntax is something like:  cp /path/to/[file1 file2] /destination/ 
>>>> folder
>>>>
>>>> But that doesn't work.  Does anybody know the correct syntax?   
>>>> Google
>>>> isn't so good at searching special characters like [ and {
>>> I do this:
>>> cp /path/to/file1 /path/to/file2 /destination/folder
>>>
>>> If the names are as similar as you wrote though, you should be able  
>>> to
>>> do this:
>>>
>>> cp /path/to/file[12] /destination/folder
>>>
>> The names really aren't that similar.  Here's the actual paths that I
>> need to copy:
>>
>> /usr/local/share/icons/Drawings.desktop
>> /usr/local/share/icons/Obsolete\ Drawings.desktop
>> /usr/local/share/icons/Obsolete\ a\ Drawing.desktop
>>
>> Since it's only 3 files, I could do as Robert suggests:
>>
>>> cp  /path/file1  /path/file2  /path/file3  /dest/dir
>> But I was hoping to find a way with less typing, just in case  
>> someday I
>> have to do this with 10 files instead of 3.
> 
> You could first change the current working directory, so you don't  
> need to supply the path to every file.
> 
> 	cd /usr/local/share/icons
> 	cp Drawings.desktop Obsolete\ Drawings.desktop Obsolete\ a\  
> Drawing.desktop /dest/dir
> 
> Nils Breunese.
> 
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
> 
> 
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
********************************************************

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If you are not the addressee, any disclosure, reproduction,
copying, distribution, or other dissemination or use of this transmission in
error please notify the sender immediately and then delete this e-mail.
E-mail transmission cannot be guaranteed to be secure or error free as
information could be intercepted, corrupted lost, destroyed, arrive late or
incomplete, or contain viruses.
The sender therefore does not accept liability for any errors or omissions
in the contents of this message which arise as a result of e-mail
transmission. If verification is required please request a hard copy
version.

********************************************************





More information about the K12OSN mailing list