- 论坛徽章:
- 0
|
还有个问题我一直弄不清楚,如何精确匹配
比如有个文本
cat volume.txt
0016h test_A40036 20000030138428920036 A4
0017h test_A40037 20000030138428920037 A4
0018h test_A40038 20000030138428920038 A4
0019h test_A40039 20000030138428920039 A4
cat volume_check.txt
test_A40036
test_A40037
test_B10001
test_B10002
cat test.sh
#!/bin/sh
volume_file=volume.txt
volume_check_file=volume_check.txt
while read volume
do
if sed -n '/$volume/p' $volume_file
then echo "$volume exist"
else echo "$volume is not exist"
fi
done < $volume_check_file
本意是想读出volume_check.txt的信息,然后在volume.txt里找,例如test_A40036在volume.txt里找到了就输出OK,否则输出WRANG,但是怎么全显示OK,并没有精确匹配 ,sed里是不是没有精确匹配,如果有是怎么写,还有grep里怎么写 |
|