Re: copy a directory recursively without data/files

From: Michael Tosch (eedmit_at_NO.eed.SPAM.ericsson.PLS.se)
Date: 07/29/04


Date: 29 Jul 2004 14:00:50 GMT

In article <slrncghi5o.1rg.stephane.chazelas@spam.is.invalid>, Stephane CHAZELAS <this.address@is.invalid> writes:
...
>
> > Question: while perfectly captured by the two '{}',
> > why is the first '{}' in Solaris $0 and not $1?
>
> Why not? It's what POSIX requires, and what most shells do.
>

I see that

#!/bin/sh
echo $0 $1

returns its invocation name and the first argument,

while

sh -c 'echo $0 $1' arg1 arg2

returns arg1 arg2.

So if this is always the case, one could rewrite

find . -type d -exec env d="$dest_root" sh -c '
  exec mkdir -p -- "$d/$1"' '{}' '{}' \;

always as

find . -type d -exec env d="$dest_root" sh -c '
  exec mkdir -p -- "$d/$0"' '{}' \;

-- 
Michael Tosch
IT Specialist
HP Managed Services
Technology Solutions Group
Hewlett-Packard GmbH
Phone: +49 2407 575 313
Mail: michael.tosch:hp.com


Relevant Pages

  • Re: difference between `` and $()
    ... many shells don't parse as robust as you might have expected. ... wrongly terminates the command substitution in many shells: ... as is echo "`pwd" and echo `'pwd`. ...
    (comp.unix.shell)
  • Re: difference between `` and $()
    ... many shells don't parse as robust as you might have expected. ... unbalanced single, double or back quote at EOF. ...
    (comp.unix.shell)
  • OK, ich sag ja schon nichts mehr
    ... Mit POSIX und SUSv3 ... Die einzigste die in allen Bourne-Shell kompatiblen Shells funktioniert ... > dort nach), ich bezweifle aber, dass FreeBSD standardmäßig irgendeine ... Next by Date: ...
    (de.comp.os.unix.linux.misc)
  • Re: bash question ... echo subtleties
    ... echo ignore both these conventions. ... I think it is a POSIX feature. ... intentional and claimed by GNU. ... Note that the Unix spec goes further in ...
    (comp.unix.shell)
  • Re: Why is testing x$foobar = "x" better than $foobar = "" ?
    ... will work with every Bourne-like shell (not only POSIX ones). ... to non-POSIX shells. ... only need it in a Bourne script or to work around bugs in some ...
    (comp.unix.shell)

Loading