当前位置: 技术问答>linux和unix
看看这个编程题目!!!!
来源: 互联网 发布时间:2016-01-05
本文导语: Write a shell script to check the items of a designated directory which must be input from your terminal: if the item is a directory, delete it; else print the name of this item. | #!/bin/sh echo "read directory name...
Write a shell script to check the items of a designated directory which must be input from your terminal: if the item is a directory, delete it; else print the name of this item.
|
#!/bin/sh
echo "read directory name:"
read Ddir
if [ -d $Ddir ]; then
echo "${Ddir} is exists"
if [ -w $Ddir ]; then
rm -rf $Ddir
echo "Remove completed!"
else
echo "You don't have the permission to remove it!"
fi
else
echo "The directory ${Ddir} is not exists!"
fi
echo "read directory name:"
read Ddir
if [ -d $Ddir ]; then
echo "${Ddir} is exists"
if [ -w $Ddir ]; then
rm -rf $Ddir
echo "Remove completed!"
else
echo "You don't have the permission to remove it!"
fi
else
echo "The directory ${Ddir} is not exists!"
fi