mac 哪个是 more 命令?怎么写,怎么 limit 每次输出行数?

2019-08-29 18:29:25 +08:00
 gIrl1990

wiki/More_(command)

more [options] [file_name]
-num: This option specifies an integer which is the screen size (in lines).
1934 次点击
所在节点    问与答
12 条回复
azh7138m
2019-08-29 18:49:17 +08:00
less
Less is a program similar to more (1)
gIrl1990
2019-08-29 18:57:41 +08:00
@azh7138m 想要那种每次输出一部分在终端里面,而不是
cat 输出全部
less 0 输出
head 输出头部但不能续读
misaka19000
2019-08-29 19:27:43 +08:00
less is more
sleepm
2019-08-29 19:37:35 +08:00
写的很清楚了,more -num filename
再举个例子 rm -rf / 一般我们写 rm / -rf 但是在 mac 中 -rf 会被当成文件
azh7138m
2019-08-29 19:50:00 +08:00
这个需求是 split
shell 循环读输出就行
gIrl1990
2019-08-29 20:13:23 +08:00
@sleepm 你好像没理解我意思,我 APPEND 了再看看
@azh7138m 我 APPEND 了再看看
azh7138m
2019-08-29 20:39:20 +08:00
我觉得是个 X-Y PROBLEM
https://coolshell.cn/articles/10804.html
gIrl1990
2019-08-29 20:48:54 +08:00
@azh7138m 不对吧,split 会产生文件,不是我想要的
azh7138m
2019-08-29 20:57:03 +08:00
如果你坚持用 shell 处理,直接读入数组,每一项就是一行
我还是觉得是个 X-Y PROBLEM
为了一个不存在的问题,在反复 hack
jmc891205
2019-08-29 21:20:48 +08:00
less 没有你想要的功能
gIrl1990
2019-08-30 10:15:51 +08:00
MacOS:
```bash
> gsha1sum /usr/bin/more /usr/bin/less
6f6ec068da5870eb28b04d0cc50abc5ec5e4b85e /usr/bin/more
6f6ec068da5870eb28b04d0cc50abc5ec5e4b85e /usr/bin/less
# 这两个是同一个文件?
> more --version
less 487 (POSIX regular expressions)
Copyright (C) 1984-2016 Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less
> more -n 3 long.txt
# 可以实现 linux 里 more 的效果
> less -n 3 long.txt
# 既然是同样文件,为何出错?
```
那如果他们不同,从 Homepage 下载到的源码如何编译出 more 命令?
gIrl1990
2019-08-31 14:13:18 +08:00
See: https://github.com/gwsw/less/issues/23
```bash
more -n 3 long.txt
more -n3 long.txt
```

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/596299

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX