coreutils
[Top][All Lists]
Advanced

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

find !(*.iso) -exec rm '{}' + fails when encounters filename beginning w


From: Graham Lawrence
Subject: find !(*.iso) -exec rm '{}' + fails when encounters filename beginning with -
Date: Mon, 21 Nov 2011 11:48:38 -0800

find !(*.iso) -exec rm '{}' +    # remove all but *.iso, needs shopt -s extglob

The above command failed when it encountered a filename beginning with
"-", generating

find: unknown predicate `-WWW.UNITED-FORUMS.CO.UK-.nfo'

Assuming find was interpreting the filename as an option, I tried
hiding it behind -iname, as

find -iname !(*.iso) -exec rm -f {} +

which produced

find: paths must precede expression: CARRIE.mds

I tried every variation I could think of to specify the path to the
current directory before -iname, and single and double quoting
!(*.iso) both inside and outside the parentheses, but still could not
do better than

find: paths must precede expression: CARRIE.mds

By sort order, CARRIE.mds is one from the last file in the directory,
so find has apparently processed 90+ files before it reached
CARRIE.mds (including `-WWW.UNITED-FORUMS.CO.UK-.nfo').  The file that
immediately precedes it is the one file I want to keep, CARRIE.iso.
Would that perhaps have something to do with it erroring out at this
point



reply via email to

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