shell脚本删除指定目录下特定文件

急求
2025-03-20 01:27:53
推荐回答(1个)
回答1:

#!/bin/bash
# Your Answer

DIR=/your/target/dir
EXT=*.txt    # may be another file type

if [ test -d $DIR ]; then
    cd $DIR
    rm -f $EXT
    echo Remove $DIR/$EXT Success
else  
    echo $DIR not exist or not a directory
fi