Re: [OT] shell quoting

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

 




I need to compare two different versions of a source tree
excluding certain directories and print out some statistics
on the files which have been changed, removed or added.

Here comes a boiled down example of the problem I'm having.
Let's say there are 4 files in the current directory:

./aa
./aaa
./bb
./bbb

and I want to exclude all paths starting with ./bb
This one is easy:

find . ! -path './bb*'

Now I want to make it into a generic script:

DIR=.
OPT='! -path $DIR/bb*'
find $DIR $OPT

$DIR and * within OPT are essential
and no matter what I've tried I can't get the parameter expansion right.

Any suggestions will be appreciated,

I couldn't get * to expand later either.  Backslashes didn't help.  What I
finally did was like:

    opt1='! -path $dir/bb<wild>'
    opt = `echo $opt1 | sed 's|<wild>|*|'`
    find $dir $opt

Hi Tony,
Actually I was trying to achieve just the opposite: to prevent * expansion.
And the only solution I've found so far was to explicitly forbid
pathname expansion with shell -f option:

DIR=.
OPT='! -path '$DIR'/bb*'
set -f
find $DIR $OPT


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux