bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HELP ON CP COMMAND


From: Eric Blake
Subject: Re: HELP ON CP COMMAND
Date: Sun, 23 Apr 2006 14:37:33 +0000

> RESPECTED SIRS,

A word of advice - typing with caps lock on is considered
shouting in web forums.  Also, it is not necessary to repeat
the text of your mail in html; plain text is sufficient.

> 
> IN DOS:
> 
> COPY *.GNT  *.gnt -> IT COPIES ALL THE FILES WITH EXTENSION *.GNT AS *.gnt
> 

DOS does not follow Unix conventions.  In DOS, all programs
do globbing themselves, so if you were to write your own
version of COPY in C, it would see argv of "COPY", "*.GNT",
"*.gnt".  But I just tried the example as you typed, and got
different behavior than what you describe:
c:\> touch file1.GNT file2.GNT
c:\> COPY *.GNT *.gnt
file1.GNT
File cannot be copied onto itself
        0 file(s) copied
c:\>

So I don't know what you are really attempting.

> IN linux:
> example:
> 
> -RWXR-X--- 1 ROOT ROOT 11093 APR23  08:07   GAE010.GNT
> -RWXR-X--- 1 ROOT ROOT 11094 APR23  08:07    GAE110.GNT

Your caps lock key seems to be stuck.  I don't know any Unix ls
implementation where the file permissions display in all caps.

> 
> The above files at a stretch to copy in to the same file name but with 
> extension 
> *.gnt
> 
> i.e.   ]   cp   *.GNT   *.gnt  - >    This is not doing the required

It is doing exactly what POSIX requires, the problem is that
what POSIX requires does not match with what you desire.
Here, a C implementation of cp would see argv as
"cp", "GAE010.GNT", "GAE110.GNT", "*.gnt".  And in Unix,
since globbing is done by the shell and not by the cp
utility, cp tries to interpret "*.gnt" as a directory name, and
fails because it does not exist.

> 
>         ]  echo cp *.GNT *.gnt ->   This is not doing the required 

This was just to show you how the shell does globbing.  It
does not actually perform the copy.

> 
>         ] rename 's/.GNT$/.gnt'  *.GNT   ->  this is not doing the required

You left out a trailing slash (and since you did not output the
actual error message that you encountered, we cannot diagnose
whether fixing your typo would work for you or if you also need to
find and install a rename script for your platform).  The suggestion
was to try "rename 's/.GNT$/.gnt/' *.GNT".

-- 
Eric Blake




reply via email to

[Prev in Thread] Current Thread [Next in Thread]