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
|
# remove all core files
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat<<USAGE
|
||||||
|
Usage: ${0##*/} [OPTIONS] [dir1] .. [dirN]
|
||||||
|
options:
|
||||||
|
-help | -h help
|
||||||
|
|
||||||
|
Remove all core files
|
||||||
|
USAGE
|
||||||
|
}
|
||||||
|
|
||||||
# default is pwd
|
# default is pwd
|
||||||
if [ "$#" -eq 0 ]
|
if [ "$#" -eq 0 ]
|
||||||
then
|
then
|
||||||
set -- .
|
set -- .
|
||||||
elif [ "$1" = "-h" -o "$1" = "-help" ]
|
elif [ "$1" = "-h" -o "$1" = "-help" ]
|
||||||
then
|
then
|
||||||
echo "Usage: ${0##*/} [dir1] .. [dirN]"
|
usage && exit 0
|
||||||
echo " remove all core files"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
for i
|
for i
|
||||||
do
|
do
|
||||||
if [ -d "$i" ]
|
if [ -d "$i" ]
|
||||||
then
|
then
|
||||||
echo "removing all core files: $i"
|
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
|
else
|
||||||
echo "no directory: $i" 1>&2
|
echo "no directory: $i" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|||||||
18
bin/rm~all
18
bin/rm~all
@ -29,24 +29,32 @@
|
|||||||
# remove all *~ files
|
# remove all *~ files
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat<<USAGE
|
||||||
|
Usage: ${0##*/} [OPTIONS] [dir1] .. [dirN]
|
||||||
|
options:
|
||||||
|
-help | -h help
|
||||||
|
|
||||||
|
Remove all backup *~ files
|
||||||
|
USAGE
|
||||||
|
}
|
||||||
|
|
||||||
# default is pwd
|
# default is pwd
|
||||||
if [ "$#" -eq 0 ]
|
if [ "$#" -eq 0 ]
|
||||||
then
|
then
|
||||||
set -- .
|
set -- .
|
||||||
elif [ "$1" = "-h" -o "$1" = "-help" ]
|
elif [ "$1" = "-h" -o "$1" = "-help" ]
|
||||||
then
|
then
|
||||||
echo "Usage: ${0##*/} [dir1] .. [dirN]"
|
usage && exit 0
|
||||||
echo " remove all *~ files"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
for i
|
for i
|
||||||
do
|
do
|
||||||
if [ -d "$i" ]
|
if [ -d "$i" ]
|
||||||
then
|
then
|
||||||
echo "removing all *~ files: $i"
|
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
|
else
|
||||||
echo "no directory: $i" 1>&2
|
echo "no directory: $i" 1>&2
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user