1、删除目录中指定文件
find /e/Apache/htdocs/site -name ‘index.html‘ | xargs rm
2、在指定目录下新建index.php并写入指定内容
#!/bin/bash # 在指定目录下新建index.php并写入<?php header(‘HTTP/1.1 400 Bad Request‘); ?> function getdir() { for dir in `ls $1` do filename=$1"/"$dir if [ -d $filename ] then echo "<?php header(‘HTTP/1.1 400 Bad Request‘); ?>" > $filename"/index.php" echo -e "write index.php successed\n" getdir $filename else echo $filename fi done } path="/e/Apache/htdocs/site" getdir $path