bash 读入文件

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
 

相关文章

系ubuntu 下面打开终端输入:sudo apt-get install sendmail...
依家我有1个软件goagent目录(大家懂得) 放在/home/gateman/...
其实我想讲的是 cp -L关于-L参数的解释:-L, --dereferenc...
原地址:http://www.rjgc.net/control/content/content.php?...
chroot,即 change root directory (更改 root 目录)。在 li...
简单解析下, stdin就是标准输入, stdout就是标准。举个例子...