This commit is contained in:
spiritlhl 2023-06-23 13:56:54 +00:00
parent 7b7f4c8b4d
commit 4666ea0014

View file

@ -27,7 +27,7 @@ remove_duplicate_lines() {
chattr -i "$1"
# 去除重复行并跳过空行和注释行
if [ -f "$1" ]; then
awk '!/^ *#/ && NF && !x[$0]++' "$1" > "$1.tmp" && mv -f "$1.tmp" "$1"
awk '!/^( *#|$)/ { if (!x[$0]++) print }' "$1" > "$1.tmp" && mv -f "$1.tmp" "$1"
fi
rm -rf "$1.tmp"
chattr +i "$1"