Δημοσιεύτηκε: 02 Ιουν 2013, 10:31
από Black Fox
Κώδικας: Επιλογή όλων
#!/bin/bash
args=$#

if [ "$args" -ne 1 ]; then
echo "This script works with only one parameter!"
else

filename=$1
test=1

if [ -f "$filename" ]; then
echo "The file exists.That's good!"
else

echo "The file doesn't exist or it isn't regular!"
test=0
fi

if [ -O "$filename" ]; then
echo "The file is yours.That's good!"
else
echo "The file is not yours!"
test=0
fi

echo

if [ $test -eq 0 ]; then
echo "Sorry,i can't do this!"
else
if [ ! -d ~/.my-trash ]; then
echo "Directory my-trash not found!"
echo "Creating directory my-trash..."
mkdir ~/.my-trash
fi

echo "Moving${filename} in trash directory..."
newfilename='date +%y%V'$filename
mv ./$filename ~/.my-trash/${newfilename}
fi
fi
exit