File Mem.txt
[root@mavenir Sudhakar]# cat MEM.txt | awk '{print $4,$5}'
输出:
CARD_0-1 12
CARD_0-10 13
CARD_0-11 13
CARD_0-12 28
CARD_0-13 2
CARD_0-14 2
CARD_0-2 30
CARD_0-3 13
CARD_0-4 29
CARD_0-9 24
CARD_1-1 13
CARD_1-10 28
CARD_1-11 13
CARD_1-12 28
CARD_1-13 29
CARD_1-14 13
CARD_1-2 30
CARD_1-3 13
CARD_1-4 28
CARD_1-5 10
CARD_1-6 28
CARD_1-9 13
[root@mavenir Sudhakar]# cat cardnum.txt
0-1
0-3
0-11
1-1
1-3
1-5
1-9
1-11
1-13
这两个文件我需要从MEM.txt文件中选择第二个值的值是cardnum.txt文件中存在的卡号。
输出应该是这样的
0-1 12
0-3 13
0-11 13
1-1 13
1-3 13
1-5 10
1-9 13
1-11 13
1-13 29
答案 0 :(得分:0)
现在,这应该可行。
#!/bin/bash
while lead line; do
val=$(echo "$line" | awk -F _ '{print $2}');
echo "$val";
done < mem.txt