![从多个文件中分离相同的行号](https://linux22.com/image/122995/%E4%BB%8E%E5%A4%9A%E4%B8%AA%E6%96%87%E4%BB%B6%E4%B8%AD%E5%88%86%E7%A6%BB%E7%9B%B8%E5%90%8C%E7%9A%84%E8%A1%8C%E5%8F%B7.png)
答案1
也许你想要这个:
#!/bin/bash
COUNT=0
while read -r line; do
COUNT=$(( $COUNT + 1 ))
sed -n "$COUNT{p;q}" test1.txt >> solution$COUNT.txt
sed -n "$COUNT{p;q}" test2.txt >> solution$COUNT.txt
done < test1.txt
也许你想要这个:
#!/bin/bash
COUNT=0
while read -r line; do
COUNT=$(( $COUNT + 1 ))
sed -n "$COUNT{p;q}" test1.txt >> solution$COUNT.txt
sed -n "$COUNT{p;q}" test2.txt >> solution$COUNT.txt
done < test1.txt