Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用rm和不删除脚本中的目录本身来删除目录中的文件。我看到的示例仅在目录本身中执行此操作,我想在不导航的情况下执行此操作。
rm
我试过了
rm "$(dirname $1)/filetokeep/*"
但它不工作。有什么帮助吗?
引用通配符会抑制扩展。
rm -- "$(dirname -- "$1")/filetokeep"/*
Using--确保值不能被解释为可选参数而不是位置参数(这样如果 in 命名的目录以$1a 开头,事情仍然有效-)。
--
$1
-