python 删除指定位置的文件_在linux 中,怎么用python 实现删除某个文件夹下以gc 开头的文件?...

====================================================================

#!/bin/bash

#

read -p "Please type in your Dir:" DIR

cd $DIR &> /dev/null

until [ $? -eq 0 ] ; do

echo "There is something wrong with your Dir.Please try agin."

read -p "Please type in your Dir:" DIR

cd $DIR &> /dev/null

done

echo "Testing.Please wait for a while."

ls $DIR -l |grep ".*" |grep "^total 0" &> /dev/null

if [ $? -eq 0 ]; then

echo "There is no such a file."

exit 0

else

ls -l $DIR

echo "Do you want to remove these files?"

fi

while true; do

read -p "Please type in (y/n):" TY

case $TY in

y)

rm -rf $DIR/*

exit 0

;;

n)

echo "Thank goodness"

exit 2

;;

*)

echo "There is something wrong.Please type agin."

;;

esac

done

======================================================================

说明: 由于时间仓促,这个脚本写的并不完善.

1.输入的路径必须为绝对路径!!

2.删除为直接删除 请慎用!!

3.指定路径下不论是普通文件还是其他类型文件,包括目录全部当做文件看待.

(不了解问题中的"文件"具体指的是哪一类文件)

4.经过多次测试,可直接拷贝使用而不需修改. (前提:使用bash shell)

5.由于英文能力有限,脚本中部分提示语或有语意不明之处.

取消

评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值