Scripts in bin: added -help and -0 on xargs
This commit is contained in:
22
bin/rmcore
22
bin/rmcore
@ -29,24 +29,36 @@
|
||||
# remove all core files
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
usage() {
|
||||
cat<<USAGE
|
||||
Usage: ${0##*/} [OPTIONS] [dir1] .. [dirN]
|
||||
options:
|
||||
-help | -h help
|
||||
|
||||
Remove all core files
|
||||
USAGE
|
||||
}
|
||||
|
||||
# default is pwd
|
||||
if [ "$#" -eq 0 ]
|
||||
then
|
||||
set -- .
|
||||
elif [ "$1" = "-h" -o "$1" = "-help" ]
|
||||
then
|
||||
echo "Usage: ${0##*/} [dir1] .. [dirN]"
|
||||
echo " remove all core files"
|
||||
exit 1
|
||||
usage && exit 0
|
||||
fi
|
||||
|
||||
|
||||
for i
|
||||
do
|
||||
if [ -d "$i" ]
|
||||
then
|
||||
echo "removing all core files: $i"
|
||||
find $i \( -type f -name 'core' -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -print0 | xargs -t rm 2>/dev/null
|
||||
find $i \
|
||||
\( \
|
||||
-type f \
|
||||
-name 'core' -o -name 'core.[1-9]*' -o -name 'vgcore.*' \
|
||||
\) -print0 | \
|
||||
xargs -t -0 rm 2>/dev/null
|
||||
else
|
||||
echo "no directory: $i" 1>&2
|
||||
fi
|
||||
|
||||
18
bin/rm~all
18
bin/rm~all
@ -29,24 +29,32 @@
|
||||
# remove all *~ files
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
usage() {
|
||||
cat<<USAGE
|
||||
Usage: ${0##*/} [OPTIONS] [dir1] .. [dirN]
|
||||
options:
|
||||
-help | -h help
|
||||
|
||||
Remove all backup *~ files
|
||||
USAGE
|
||||
}
|
||||
|
||||
# default is pwd
|
||||
if [ "$#" -eq 0 ]
|
||||
then
|
||||
set -- .
|
||||
elif [ "$1" = "-h" -o "$1" = "-help" ]
|
||||
then
|
||||
echo "Usage: ${0##*/} [dir1] .. [dirN]"
|
||||
echo " remove all *~ files"
|
||||
exit 1
|
||||
usage && exit 0
|
||||
fi
|
||||
|
||||
|
||||
for i
|
||||
do
|
||||
if [ -d "$i" ]
|
||||
then
|
||||
echo "removing all *~ files: $i"
|
||||
find $i \( -name '*~' -o -name '.*~' \) -print0 | xargs -t rm 2>/dev/null
|
||||
find $i \( -name '*~' -o -name '.*~' \) -print0 | \
|
||||
xargs -t -0 rm 2>/dev/null
|
||||
else
|
||||
echo "no directory: $i" 1>&2
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user