更新时间:2022-06-24 10:10:00
我会用以下内容:
awk -v RS="=====" -v OFS="," 'BEGIN {print "vFiler", "Type" } NF{print $1, $2}' file
返回的是:
vFiler,Type
vfiler0,/vol/vol0
vFiler1,/vol/vol1
我们做的是设置记录分隔符为 =====
。这样一来,块====
将每一次处理。然后,我们打印的第一和第二场,每当有至少有一个( NF
)。
What we do is to set the record separator as =====
. This way, a block of ====
will be handled every time. Then, we print the first and second field whenever there is at least one (NF
).