first commit
This commit is contained in:
51
ssh_loops/loop_array_with_flags.sh
Normal file
51
ssh_loops/loop_array_with_flags.sh
Normal file
@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
#find only directories older then 10 days
|
||||
|
||||
#this will tar and remove
|
||||
#tar -cvf /home/roy/Desktop/test/some_dir.tgz /home/roy/Desktop/test/some_dir --remove-files
|
||||
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
echo "$package - attempt to capture frames"
|
||||
echo " "
|
||||
echo "$package [options] application [arguments]"
|
||||
echo " "
|
||||
echo "options:"
|
||||
echo "-h, --help show brief help"
|
||||
echo "--days=<1-n> specify an action to use"
|
||||
echo "-o, --output-dir=DIR specify a directory to store output in"
|
||||
exit 0
|
||||
;;
|
||||
-a)
|
||||
shift
|
||||
DIR_NAME=($(find /var/log -maxdepth 1 -type d -mtime +10))
|
||||
if test $# -gt 0; then
|
||||
export PROCESS=$1
|
||||
else
|
||||
for dir in "${DIR_NAME[@]}"
|
||||
do
|
||||
echo "tar -czPf $dir.tar.gz $dir --remove-files"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--days*)
|
||||
DIR_NAME=($(find /var/log/ -maxdepth 1 -type d -mtime +$2))
|
||||
if test $# -gt 0; then
|
||||
export PROCESS=$1
|
||||
else
|
||||
for dir in "${DIR_NAME[@]}"
|
||||
do
|
||||
echo "tar -czPf $dir.tar.gz $dir --remove-files"
|
||||
done
|
||||
exit 1
|
||||
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
Reference in New Issue
Block a user