read 读取文件并将一行中的不同字段存储至不同变量中;
比如说:
cat test
zhang 10 155
wang 8 148
可以用
read name age height < test
即将每一行的三个值分别储存到变量中,方便应用在循环或条件语句,或 awk 的使用中。
或者:
cat test |
while read name age height
do
...
done
也可以通过读取文件应用到循环中。
read 读取文件并将一行中的不同字段存储至不同变量中;
比如说:
cat test
zhang 10 155
wang 8 148
可以用
read name age height < test
即将每一行的三个值分别储存到变量中,方便应用在循环或条件语句,或 awk 的使用中。
或者:
cat test |
while read name age height
do
...
done
也可以通过读取文件应用到循环中。
本文标题:read 读取文件并将变量应用在 awk 中
本文链接:https://www.haomeiwen.com/subject/chcovdtx.html
网友评论