3 ms·
> The Python and Ruby versions would be similar Not Ruby! sh = Shell.cd('/') sh.transact do system('tail -fq /var/log/nginx/access.log') | system("awk
by lloeki 3y ago
> The Python and Ruby versions would be similar
Not Ruby!
sh = Shell.cd('/')
sh.transact do
system('tail -fq /var/log/nginx/access.log') | system("awk '{print $7}" | system("sort") | system("uniq -c") | system("sort -rn")
end
Pretty sure one could get without the system method with Shell having def method_missing(meth, * args) to call system([meth.to_s, * args]) or something, turning it into:
sh.transact do
tail '-fq' '/var/log/nginx/access.log' | awk '{print $7}' | sort | uniq '-c' | sort '-rn'
end
https://github.com/ruby/shell#pipe-etcprintcap-into-a-file https://github.com/ruby/shell#pipe-etcprintcap-into-a-file