Re: recursive mv return invalid argument

From: rakesh sharma (sharma__r_at_hotmail.com)
Date: 07/03/03


Date: 2 Jul 2003 18:26:44 -0700


"Ben Thomas" <bthomas@trey-industries.com> wrote in message news:<pan.2003.07.02.19.55.30.274063@trey-industries.com>...
> this simple script :
>
> for fff in 'find ./ -type f -name *.txt'; do
> mv $fff $fff.bak
> done
>
> returns:
> mv: invalid option -- t
> Try `mv --help' for more information.

  to see what's going on with u'r case, just prepend an echo
  before 'mv' and see what happens:

        echo mv $fff $fff.bak

   to fix it,
  replace the single quotes ' by backquotes `
  & protect the *.txt by single quotes in order
  to pass them along to the find command unexpanded.

or better still, do away with the backquotes as in:

  find . -type f -name '*.txt' -exec sh -c 'mv "$1" "$1.bak"' {} {} \;

and if you have the GNU version of find, then the above can be shortened to:

  find . -type f -name '*.txt' -exec mv {} {}.bak \;



Relevant Pages

  • Re: heredoc and array problems
    ... When you echo an array variable such as $Din SINGLE QUOTES ... you need to concatenate it as single quotes means a string literal ... So the implied interpolation works only inside strings. ...
    (comp.lang.php)
  • Re: [PHP] Re: optimilize web page loading
    ... >>> doubles for the email. ... because the strings are not concatenated before output. ... adapting to using echo (to the ob to avaoid printing forty ... So, it looks like for echoing at least then single quotes are actually marginally slower than double quotes, and interpolation is faster. ...
    (php.general)
  • Re: find -print0 confusing me
    ... echo "straight call to find" ... echo "calling in backquotes" ... The NUL byte is the string terminator. ...
    (comp.unix.shell)
  • Re: find -print0 confusing me
    ... Why does the ascii nul character not appear in the string when it is ... echo, print and printf do. ... : echo "calling in backquotes" ...
    (comp.unix.shell)
  • Re: [PHP] When and when not to use and "
    ... On 6/2/07, Brian Seymour wrote: ... Single quotes give a literal value of the data passed, ... echo '$the'; ... The same counts for escaped characters, ...
    (php.general)