Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试通过管道输出这样的命令:
some_command | ruby -ne "puts $_ if some_condition($_)"
但是,我看到的只是空行。每行存储在哪里?
这应该工作得很好。例如,ls | ruby -ne 'puts $_ if $_[0] == "r"'打印出我所期望的。您应该确保您some_command实际上正在输出到标准输出。
ls | ruby -ne 'puts $_ if $_[0] == "r"'
some_command