【发布时间】:2020-07-02 08:36:13
【问题描述】:
此代码 sn-p 适用于 'dirlist.txt' 中的给定目录列表
DIR_LIST = "dirlist.txt"
exclude_legacy:
@echo "=== Checking dirs to exclude..."
while read -r dirto_exclude; \
do \
if [[ "$${dirto_exclude}" = \#.* ]]; then \
continue; \
else \
echo "Exclude this dir, $${dirto_exclude}"; \
rm -rf $${dirto_exclude}; \
fi \
done < $(DIR_LIST)
有两个问题:
-
有兴趣了解是否有更好的方法可以借助 make 的内置函数实现相同的功能。
-
运行“make -s -f Makefile”会清除“dirlist.txt”中给出的所需目录。但是,echo 语句(在 else 块中)的输出也会打印带有 cmets 的行以及在条件中被跳过的行在“if”块中给出。我希望输出仅包含要清除的那些目录名,这与预期的一样。
这是为什么?
谢谢, 维吉
【问题讨论】: