【发布时间】:2020-01-02 05:29:41
【问题描述】:
我正在使用一个脚本,该脚本在 Web 应用程序中调用 awk,扩展名为 -i inplace(在 Debian 9 上)。在真实服务器 (centOS 7) 上部署应用程序时失败,原因是 awk/gawk 无法识别 -i inplace 输入。
示例:
example.txt
one 1
two 2
three 3
尝试时:
awk -i inplace -F'\t' '{if ($1 == "two") print "four","4"; else print $0}' example.txt
输出错误:
Usage: gawk [POSIX or GNU style options] -f progfile [--] file ...
Usage: gawk [POSIX or GNU style options] [--] 'program' file ...
POSIX options: GNU long options: (standard)
-f progfile --file=progfile
-F fs --field-separator=fs
-v var=val --assign=var=val
Short options: GNU long options: (extensions)
-b --characters-as-bytes
-c --traditional
-C --copyright
-d[file] --dump-variables[=file]
-e 'program-text' --source='program-text'
-E file --exec=file
-g --gen-pot
-h --help
-L [fatal] --lint[=fatal]
-n --non-decimal-data
-N --use-lc-numeric
-O --optimize
-p[file] --profile[=file]
-P --posix
-r --re-interval
-S --sandbox
-t --lint-old
-V --version
To report bugs, see node `Bugs' in `gawk.info', which is
section `Reporting Problems and Bugs' in the printed version.
gawk is a pattern scanning and processing language.
By default it reads standard input and writes standard output.
Examples:
gawk '{ sum += $1 }; END { print sum }' file
gawk -F: '{ print $1 }' /etc/passwd
我真的需要awk 脚本才能通过inplace 工作,我在网上四处搜索但没有找到明确的解决方案,有人知道如何让它工作吗?
非常感谢您的任何帮助
【问题讨论】:
-
就地扩展相对较新。如果可能,请尝试升级您的
gawk。顺便说一句,当前版本是什么? -
PS:gawk-4.1.0中已经引入