答案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