Ben*_*ell 5 command-line pager pipe filter
我想从程序中获取输出并以交互方式过滤要通过管道传输到下一个命令的行。
ls | interactive-filter | xargs rm
Run Code Online (Sandbox Code Playgroud)
例如,我有一个模式无法匹配以减少的文件列表。我想要一个命令interactive-filter来分页文件列表的输出,我可以交互地指示要转发到下一个命令的行。在这种情况下,每行都将被删除。
iselect 提供一个上下列表,(作为先前管道的输入),用户可以在其中标记多个条目(作为下一个管道的输出):
# show some available executables ending in '*sh*' to run through `whatis`
find /bin /sbin /usr/bin -maxdepth 1 -type f -executable -name '*sh' |
iselect -t "select some executables to run 'whatis' on..." -a -m |
xargs -d '\n' -r whatis
Run Code Online (Sandbox Code Playgroud)
按空格键在我的系统上标记一些后输出:
dash (1) - command interpreter (shell)
ssh (1) - OpenSSH SSH client (remote login program)
mosh (1) - mobile shell with roaming and intelligent local echo
yash (1) - a POSIX-compliant command line shell
Run Code Online (Sandbox Code Playgroud)vipe允许交互式编辑(使用自己喜欢的文本编辑器)通过管道的内容。例子:
# take a list of executables with long names from `/bin`, edit that
# list as needed with `mcedit`, and run `wc` on the output.
find /bin -type f | grep '...............' | EDITOR=mcedit vipe | xargs wc
Run Code Online (Sandbox Code Playgroud)
输出(在 in 中删除一些行之后mcedit):
378 2505 67608 /bin/ntfs-3g.secaudit
334 2250 105136 /bin/lowntfs-3g
67 952 27152 /bin/nc.traditional
126 877 47544 /bin/systemd-machine-id-setup
905 6584 247440 total
Run Code Online (Sandbox Code Playgroud)推拉注意事项:
iselect从一个没有选择任何内容的列表开始。 vipe从一个列表开始,其中显示的每个项目都将通过管道发送,除非用户删除它。在基于Debian的发行版中,这两个工具都可以使用apt-get install moreutils iselect.