【发布时间】:2017-11-01 10:52:04
【问题描述】:
我是脚本新手,遇到以下问题: 1. 在文本文件中获取“file:”值后,它应该跳过 2 行,然后从第 2 行读取
(--如果我在 txt 文件中找到“文件:”,我想跳过 2 行。这可能发生超过 1 次)。
i/p 文件是:
file : noki lab:3232 date : 12/3/16
field length position text
name 16 0 1 account name
info 1 10 Bank account info
city 3 0 13 bank acc city name
state 4 17 acc state
--这里我想跳过我在 txt 文件中找到“文件:”的 2 行。有可能发生超过 1 次。
-
阅读后我只想选择“归档”和“位置”列数据。 代码:
awk -F ' ' '{print $1,$3}' ip.txt
但我得到了 o/p 之类的:
name 0
info 10
city 0
state 17
这是错误的,我需要输出:
name 1
info 10
city 13
state 17
【问题讨论】: