我正在尝试编写一个bourne-shell脚本,该脚本接受一个字符串作为参数,并删除目录中包含该字符串的所有文件。我正在考虑使用find和execute rm,但我刚刚启动了b-shell。
find . -name $1 'core' -exec rm -i* {}\;
任何帮助都将不胜感激。谢谢。
发布于 2012-03-02 12:57:13
remove.sh脚本:
#!/bin/sh
find . -type f -iname *$1* -exec rm -rf {} \;用法:
$remove.sh "main"发布于 2012-03-10 22:59:34
为什么不是这样:
#!/bin/sh
rm *$1*移除当前目录中包含参数的文件。
发布于 2013-11-06 19:28:31
find . -type f -name "$1" -delete这将递归到所有子目录中。如果你不想这样做,那就使用rm或-maxdepth 1。
https://stackoverflow.com/questions/9528132
复制相似问题