[Top][All Lists]

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

Re: cp command bug

From: Bob Proulx
Subject: Re: cp command bug
Date: Tue, 28 May 2002 02:34:32 -0600

> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">

In the future it would be most appreciated if you did not send HTML
mail to mailing lists.  Plain text is strongly recommended.


> I accidently typed the following:&nbsp;&nbsp; cp *inc</FONT></DIV>
> <DIV><FONT face=Arial size=2>I had two files that matched in the
> directory.&nbsp; </FONT><FONT face=Arial size=2>The first match
> copied on top of the second match.</FONT></DIV> <DIV><FONT
> face=Arial size=2>I see no idea why anybody would expect this
> result.&nbsp; This should be sealed off and return an error message
> since&nbsp;this action destroyed a file of mine I had to recover

Unfortunately the cp command only sees what the shell expands first.
Your shell is expanding the * character into individual matching
filenames.  The cp command never new that you had typed in '*'.  It
saw only that you had told it to copy one file to another.

Try this.  You will see by the echo command what cp saw as arguments.
I can only think that as a workaround you might want to use the cp -i

  echo cp *inc

Prints out:

  cp a.inc b.inc

You might want to check out the FAQ and look in the sections that talk
about using echo to see what the shell does to the command line.  Look
in the sections with 'globbing'.


Hope that helps.

reply via email to

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