Suppose we have a file contains the following information, termed input_file:
A 0
B 1
C 2
1. Read file one per line
(1):
while read line
do
printf "$linen"
done <data
(2):
exec 6 <data # create a file handler
while read line 0<&6
do
printf "$linen"
done
exec 6<&- # close file
2. Read and parse each line
while read x y
do
echo $x $y
done <data
3.Read a file with user-specified delimiter
e.g. (file name: data)
A:0
B:1
C:2
IFS=: # set delimiter, delimiter is white space by default
while read x y
do
printf "$xt$yn"
done <data
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。