我正在尝试学习本章作业的 AWK 命令,他们作为命令给出的示例之一是:
awk -F: '{printf "%s\t %s\n", $1, $2}' datafile
虽然我了解这些术语中的大部分,但我不知道"%s\t %s\n"
所指的是什么。我似乎无法找到他们在这个命令中的目的究竟是什么。任何反馈都会有所帮助,因为我是 linux 一年级的学生,话虽如此,请尽量不要过于技术性地回复
The first %s
is where the value of $1
will be placed.
The second %s
is where the value of $2
will be placed.
\t
is a tab.
\n
is a newline.
awk -F:
将字段分隔符设置为:
'{printf "%s\t %s\n", $1, $2}'
打印字段 nr1 选项卡字段 nr2 输入
数据文件
更多细节
"%s
#get first filed ($1)
\t
#tab + 一个空格
%s
#get second filed ($2)
\n
#add a new line
"
, $1
#fist field
, $2
#second field
另见此处:http ://www.gnu.org/software/gawk/manual/html_node/Printf-Examples.html