由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - 菜鸟问:getline找不到,该如何安装?
相关主题
怎么让sftp自动补全?你们又胡说了,牛人明明都是用cat做编辑器的
还是关于用GPL code的问题请教gnuplot高手
gedit crash (RHEL)Bash 里一个简单诡异的问题 (转载)
不是说好了debian8今天发布么问个自动安装软件的问题
请问如何用sort命令给数据排序?sqlquery里的值,如何赋值给外面的linux变量?
terminal下怎么对齐table的列?越用越觉得c好用
请问怎么把两个行数相等的文件合并起来?码工码农,帮忙了! (转载)
grep 的问题TCSH里怎么用setenv把一个带有空格的路径加给$PATH? (转载)
相关话题的讨论汇总
话题: getline话题: license话题: gnu话题: awk话题: public
进入Linux版参与讨论
1 (共1页)
d******i
发帖数: 7160
1
在自学shell。经常发现这个getline冒出来。
可我的环境总说找不到。
感觉像是c的函数啊。在shell里用的挺多。
咋安装呢?
谢谢!
v*s
发帖数: 29
2
来个具体的例子

【在 d******i 的大作中提到】
: 在自学shell。经常发现这个getline冒出来。
: 可我的环境总说找不到。
: 感觉像是c的函数啊。在shell里用的挺多。
: 咋安装呢?
: 谢谢!

d******i
发帖数: 7160
3
输入重定向(getline)
getline 函数用来从标准输入,例如管道或者文件来读入数据,而不是
从正被处理的当前文件。getline 取得输入的下一行,并更新NF、NR
和FNR等内置变量的值。如果getline找到记录则返回1,达到EOF(文
件结束)则返回0。如果有错误则返回-1。

举例1:
$ nawk 'BEGIN{"date"|getline d;print d}' datafile
2005年05月06日 星期五 15时05分41秒 CST
解释:执行date命令,然后把输出从管道送到getline,并赋给自
定义变量d,然后打印d。
— 举例2:
$nawk 'BEGIN{while("ls"|getline) print}'
awk.sc2
datafile
datafile2
employees
employees2
lab5.data
names
passwd
解释:将把ls的输出送到getline。对于每次循环,getline都从
ls读取一个以上输出,然后打印到屏幕上
好像getline不认得,运行不了。
s*******e
发帖数: 326
4
应该是awk里的一个函数,我跑这两个例子都没问题
你的awk版本是多少,什么系统

【在 d******i 的大作中提到】
: 输入重定向(getline)
: getline 函数用来从标准输入,例如管道或者文件来读入数据,而不是
: 从正被处理的当前文件。getline 取得输入的下一行,并更新NF、NR
: 和FNR等内置变量的值。如果getline找到记录则返回1,达到EOF(文
: 件结束)则返回0。如果有错误则返回-1。
: —
: 举例1:
: $ nawk 'BEGIN{"date"|getline d;print d}' datafile
: 2005年05月06日 星期五 15时05分41秒 CST
: 解释:执行date命令,然后把输出从管道送到getline,并赋给自

d******i
发帖数: 7160
5
我装的是gnuwin32。里面的awk版本如下。
不会连这个也是阉割版的吧?
c:\XXX>awk --version
GNU Awk 3.1.6
Copyright (C) 1989, 1991-2007 Free Software Foundation.
This program is free software; you can redistribute it and/or modi
it under the terms of the GNU General Public License as published
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.

【在 s*******e 的大作中提到】
: 应该是awk里的一个函数,我跑这两个例子都没问题
: 你的awk版本是多少,什么系统

x****s
发帖数: 921
6
try cygwin

【在 d******i 的大作中提到】
: 我装的是gnuwin32。里面的awk版本如下。
: 不会连这个也是阉割版的吧?
: c:\XXX>awk --version
: GNU Awk 3.1.6
: Copyright (C) 1989, 1991-2007 Free Software Foundation.
: This program is free software; you can redistribute it and/or modi
: it under the terms of the GNU General Public License as published
: the Free Software Foundation; either version 3 of the License, or
: (at your option) any later version.
: This program is distributed in the hope that it will be useful,

1 (共1页)
进入Linux版参与讨论
相关主题
TCSH里怎么用setenv把一个带有空格的路径加给$PATH? (转载)请问如何用sort命令给数据排序?
请问一个文件区段替换的问题terminal下怎么对齐table的列?
如何把session翻译成中文?请问怎么把两个行数相等的文件合并起来?
菜鸟 wget 问题求教grep 的问题
怎么让sftp自动补全?你们又胡说了,牛人明明都是用cat做编辑器的
还是关于用GPL code的问题请教gnuplot高手
gedit crash (RHEL)Bash 里一个简单诡异的问题 (转载)
不是说好了debian8今天发布么问个自动安装软件的问题
相关话题的讨论汇总
话题: getline话题: license话题: gnu话题: awk话题: public