main logo
Subject: Re: [ProLinux] cp command
Author: Carl Karsten
Posted: 2008/04/30 10:18:40
 
View Entire Thread
New Search


Peter Cushing wrote:
> Hi All,
>
> Just been using knoppix 5.1 to try to get some stuff off a laptop before
> reinstalling/repairing windows. Booted up fine and found the documents
> and settings/xxx user/ folder and put in a memory stick to copy to.
> Unfortunately when I marked the contents of the folder and copied, then
> pasted onto the stick it seemed to take an age going through the folders
> before even starting the copy. After a while I brought up a console and
> cd'd to the correct folder //media/hda2/etc..
> I wanted to just copy the entire contents including subfolders to the
> stick with (I think):
>
> cp -R *.* //media/sda1
>
>
> Trouble is this only copied the main folder and not the subfolders.

I bet your sub folders did not have a dot in them.

cp -R * //media/sda1

* matches everything. *.* matches with a . somewhere between 2 sets of everythings.

I have no idea why *.* works the way it does in dos.


note: file name globbing is a bash/shell thing. most commands have no concept
of wild cards, they just want a list of parameters. If you look closely at the
cp syntax:

Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

multiple sources is done by specifying each one, not by suppling a wild card.

This probably still doesn't jive, so lets look at some examples:

carl (AT) dell29:~$ echo *
a b backups batcave1 DOT flw batcave1.flw~ bin...qemu resume.html sound.wav
sources.list.gutsy.cached Splash.aspx src temp

The echo command does not know about file names or wild cards, it just echos
what ever parameters you give it. it echoed all that stuff, because bash
expanded the * to the list of files in the dir, and passed that to echo.

carl@dell29:~$ echo *.*
batcave1.flw batcave1.flw~ ... resume.html sound.wav sources.list.gutsy.cached
Splash.aspx

if I wanted to copy those files to /tmp, I could do:

cp batcave1.flw batcave1.flw~ resume.html sound.wav sources.list.gutsy.cached
Splash.aspx /tmp

or, cp *.* /tmp

and one last trick: to 'test' commands to see what they will see, but not
actually execute:

$ echo cp *.* /tmp
cp batcave1.flw batcave1.flw~ resume.html sound.wav sources.list.gutsy.cached
Splash.aspx /tmp


Carl K



> The
> help said -R or -r was recursive but didn't seem to work.
> I'm sure it's an easy one for you guys :-)
>
> The laptop has now run out of battery and waiting for the lead to come
> in tomorrow so I can have another go.
>
> TIA
>
> Peter
>
>
> ----------------------------------------------------------------------------------------
> This communication and the information it contains is intended for the person or organisation to whom it is addressed.Its contents are confidential and may be protected in law. Unauthorised use, copying or disclosure of any of it may be unlawful.If you have received this message in error, please notify us immediately by telephone or email.
>
>
> While Rajan Imports has taken every reasonable precaution to minimise the risk of virus transmission through email, we cannot accept liability for any damage which you sustain as a result of software viruses.
> It is the responsibility of the recipient to ensure that they have adequate virus protection.
>
> www.rajan-group.co.uk
>
> Rajan Imports Ltd
> Head Office:61 Great Ducie Street, Manchester M3 1RR. Tel:0161 831 3700 Fax:0161 831 3715
>
> London Office:17-19 Foley Street, London W1W 6DW Tel:0207 299 7960
>
>
>
>
[excessive quoting removed by server]


 
©2008 Carl Karsten
<-- Prior Message New Search Next Message -->