相关疑难解决方法(0)

关闭管道中的缓冲

我有一个调用两个命令的脚本:

long_running_command | print_progress
Run Code Online (Sandbox Code Playgroud)

long_running_command打印的进展,但我很不满意它。我正在使用print_progress使其更好(即,我在一行中打印进度)。

问题:将管道连接到标准输出也会激活一个 4K 缓冲区,所以漂亮的打印程序什么都没有……什么都没有……什么都没有……很多……:)

如何禁用4K缓冲区long_running_command(不,我没有源)?

shell pipe buffer

475
推荐指数
9
解决办法
26万
查看次数

grep 在 nc 输出中不匹配

我正在使用nc扫描开放端口,但我扫描的范围很广,并且显示的结果太多。grep出于某种原因,尝试使用“成功”这个词是行不通的:

$ nc -zv localhost 31000-32000 | grep succeeded
...
nc: connect to localhost port 31957 (tcp) failed: Connection refused
nc: connect to localhost port 31958 (tcp) failed: Connection refused
nc: connect to localhost port 31959 (tcp) failed: Connection refused
Connection to localhost 31960 port [tcp/*] succeeded!
nc: connect to localhost port 31961 (tcp) failed: Connection refused
nc: connect to localhost port 31962 (tcp) failed: Connection refused
nc: connect to localhost port 31963 (tcp) failed: Connection …
Run Code Online (Sandbox Code Playgroud)

grep terminal netcat

4
推荐指数
1
解决办法
4385
查看次数

标签 统计

buffer ×1

grep ×1

netcat ×1

pipe ×1

shell ×1

terminal ×1