bourne shell查找删除



我正在尝试编写一个bourneshell脚本,该脚本将字符串作为参数,并删除包含该字符串的目录中的所有文件我一直在考虑使用find-and-execute rm all,但我刚刚开始使用b-shell

find . -name $1 'core' -exec rm -i* {};

任何帮助都将不胜感激。谢谢

为什么不只是这个:

#!/bin/sh
rm *$1*

删除当前目录中包含参数的文件。

remove.sh脚本:

#!/bin/sh
find . -type f -iname *$1* -exec rm -rf {} ;

用法:

$remove.sh "main"

最新更新