全部:
我正在尝试使用两个循环来检查 $new 字符串是否已存在于存在列表中。
但是,$p 字符串似乎并没有在内循环之外持续存在以强制外循环中断。
#!/bin/sh
p=0
while read new; do
while read exist; do
echo "$new - $exist"
if [ "$new" = "$exist" ]; then
#echo "$new - $exist"
p=1
echo "$p"
break
fi
done<existlist
if [ $p -ne 1 ]; then
echo "$p"
break
fi
done<newlist
echo "#$new#"
这可能是一个范围问题,但我不确定。
非常感谢您的帮助。
谨此,
加里
为什么不使用 grep 呢?
#!/bin/sh
阅读 MYSTR 时;做
grep "$MYSTR" 存在列表
如果 [ $? -eq 0];然后
echo "$MYSTR 存在于新列表中"
休息
菲
完成