We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
假定, tail -f log 会不断输出类似下面日志内容
tail -f log
2013-12-03 10:20:26,889 [nioEventLoopGroup-2-3] DEBUG i.n.handler.logging.LoggingHandler - [id: 0x456ea7b0, /10.68.199.85:36714 => /10.125.48.164:7769] WRITE(42B) +-------------------------------------------------+ | 0 1 2 3 4 5 6 7 8 9 a b c d e f | +--------+-------------------------------------------------+----------------+ |00000000| 34 30 31 0a 76 69 61 3a 74 63 70 3a 2f 2f 31 30 |401.via:tcp://10| |00000010| 2e 36 38 2e 31 39 39 2e 38 35 3a 33 36 37 31 34 |.68.199.85:36714| |00000020| 0a 6d 69 64 3a 32 20 30 0a 0a |.mid:2 0.. | +--------+-------------------------------------------------+----------------+ 2013-12-03 10:20:26,889 [nioEventLoopGroup-2-3] DEBUG i.n.handler.logging.LoggingHandler - [id: 0x456ea7b0, /10.68.199.85:36714 => /10.125.48.164:7769] FLUSH 2013-12-03 10:20:27,089 [nioEventLoopGroup-2-3] DEBUG i.n.handler.logging.LoggingHandler - [id: 0x456ea7b0, /10.68.199.85:36714 => /10.125.48.164:7769] RECEIVED(406B)
现, 需要写段 scala 脚本, 使得 tail -f log | scala script.scala 后输出:
scala
tail -f log | scala script.scala
2013-12-03 10:20:26,889 /10.68.199.85:36714 => /10.125.48.164:7769 WRITE(42B) 401 via:tcp://10.68.199.85:36714 mid:2 0 2013-12-03 10:20:26,889 /10.68.199.85:36714 => /10.125.48.164:7769 FLUSH 2013-12-03 10:20:27,089 /10.68.199.85:36714 => /10.125.48.164:7769 RECEIVED(406B)
你实现了吗?
嗯, 不错! 然我们提升一点难度, 让你的脚本支持一个 关键字 的参数, 使得执行tail -f log | scala script.scala "401"后输出上面的内容不变, 而执行tail -f log | scala script.scala "400"后则输出:
tail -f log | scala script.scala "401"
tail -f log | scala script.scala "400"
2013-12-03 10:20:26,889 /10.68.199.85:36714 => /10.125.48.164:7769 WRITE(42B) 2013-12-03 10:20:26,889 /10.68.199.85:36714 => /10.125.48.164:7769 FLUSH 2013-12-03 10:20:27,089 /10.68.199.85:36714 => /10.125.48.164:7769
请务必用函数的思维来实现你的脚本!
The text was updated successfully, but these errors were encountered:
http://blog.richdougherty.com/2009/04/tail-calls-tailrec-and-trampolines.html
Sorry, something went wrong.
https://gist.github.com/zhongl/7787942#file-log_filter-scala
No branches or pull requests
假定,
tail -f log
会不断输出类似下面日志内容现, 需要写段
scala
脚本, 使得tail -f log | scala script.scala
后输出:你实现了吗?
嗯, 不错! 然我们提升一点难度, 让你的脚本支持一个 关键字 的参数, 使得执行
tail -f log | scala script.scala "401"
后输出上面的内容不变, 而执行tail -f log | scala script.scala "400"
后则输出:The text was updated successfully, but these errors were encountered: