【发布时间】:2015-10-21 04:07:12
【问题描述】:
这看起来很傻,但我还没有找到一个工具可以做到这一点,所以我想我只是想在尝试自己编写代码之前先确定一个工具不存在:
有没有简单的方法来cat 或less 文件的特定行?
我希望有这样的行为:
# -s == start && -f == finish
# we want to print lines 5 - 10 of file.txt
cat -s 5 -f 10 file.txt
即使是更简单的东西也会受到赞赏,但我只是不知道有什么工具可以做到这一点:
# print from line 10 to the end of the file
cat -s 10 file.txt
我认为这两个功能都可以通过 head、tail 和 wc -l 的混合轻松创建,但也许有一些我不知道的内置函数可以做到这一点?
【问题讨论】:
标签: macos shell command-line terminal