!(UsageRequest.csv)
is a ksh
globbing operator, it only works with ksh
(also with zsh -o kshglob
or bash -O extglob
, but those shells don't come by default on Solaris).
So you need to run those commands in ksh
. Note that the /bin/sh
of Solaris 11 is now based on ksh93, so it would work there, but you still shouldn't use those non-standard extensions in sh
scripts there.
On Solaris 10 and earlier, /bin/sh
is a Bourne shell. The standard sh
is to be found elsewhere in /usr/xpg4/bin/sh
. That sh
is based on ksh88
. Again !(x)
would work there, but shouldn't be used there.
So, use:
#! /usr/bin/ksh -
rm -- !(UsageRequest.csv)
Or:
#! /usr/xpg4/bin/sh -
ksh -c 'rm -- !(UsageRequest.csv)'
POSIX (or Bourne) globs don't have negation operators. You'd need to do cumbersome things like:
set -- *
for i do
[ UsageRequest.csv = "$i" ] || set -- "$@" "$i"
shift
done
rm -- "$@"
Or you could use find
:
find . ! -name . -prune ! -name '.*' ! -name 'UsageRequest.csv' \
-exec rm -f {} +
find
? – phk Aug 30 '16 at 09:18shopt -s extglob
beforerm !(file.txt)
? this work on a solaris 10. – Archemar Aug 30 '16 at 09:22