如何读取每一行,然后将每个字符串设置为单独的变量。
例如:
555 = a
abc = b
5343/abc = c
22 = d
2323 = e
233/2344 = f
test1.text
555 abc 5343/abc
444 cde 343/ccc
test2.txt
22 2323 233/2344
112 223 13/12
echo$a$d$f
期望输出:
555 22 233/2344
444 112 13/12
下面的脚本将每行设置为变量,但我将每行中的字符串设置为变量。
paste test1.txt test2.txt | while IFS="$(printf 't')" read -r f1 f2
do
printf 'codesonar %s %sn' "$f1 $f2"
done
您必须在read
中使用所需的变量。
$: paste test1.txt test2.txt |
> while read a b c d e f g h i j k l m n o p q etc
> do echo $a $d $f
> done
555 22 233/2344
444 112 13/12
我是不是错过了什么?