删除常规文件及隐藏文件shell脚本

脚本样例

#!/bin/bash

E_WRONG_DIRECTORY=73

clear

TargetDirectory=/opt

cd $TargetDirectory
echo "Deleting stale files in $TargetDirectory."

if [ "$PWD" != "$TargetDirectory" ];then
  echo "Wrong directory!"
  echo "In $PWD,rather than $TargetDirectory!"
  echo "Bailing out!"
  exit $E_WRONG_DIRECTORY
fi

rm -rf *
rm -rf .[A-Za-z0-9]*

echo
echo "Done."
echo "Old files deleted in $TargetDirectory."
echo

exit 0

你可能感兴趣的:(linux,shell,linux,服务器,数据库,shell)