我希望从我网站的访问日志中看到实时输出。我想只看到certail类型的条目,在这种情况下,条目匹配" .php"。
这很好用,但是换行包含在下一行,我不想要:
tail -f access-log | fgrep ".php" --line-buffered
这适用于避免换行,但不会过滤:
less +F -S access-log
我更喜欢查看没有换行到下一行的文件,因为在输出中更容易看到结构,这就是我想要的less -S
。
这种作品,但"光标"不会停留在文件的底部,我输入的任何命令都会使less
挂起(按" SHIFT + f"在流来时停留在底部):
tail -f access-log | fgrep ".php" --line-buffered | less -S
但这根本不起作用:
tail -f access-log | fgrep ".php" --line-buffered | less +F -S
那么,有没有办法实现我想要的呢?
我也采取了开箱即用的解决方案,可能会使用sed
切割,以便每一行都不会长于我的屏幕?
答案 0 :(得分:1)
我建议用bash:
tail -f access-log | fgrep ".php" --line-buffered | cut -c 1-$COLUMNS
答案 1 :(得分:0)
考虑使用class Area < ApplicationRecord
has_many :spending
has_many :trip
end
class Spending < ApplicationRecord
belongs_to :area
end
class Trip < ApplicationRecord
belongs_to :area
end
命令:
watch
答案 2 :(得分:0)
我已经在我的案例中使用了接受的答案,但我想如果我真的想少用,因为我喜欢它提供的其他功能,我可以这样做:
tail -f access-log | fgrep ".php" --line-buffered >> tmp.access-log
然后
less -S +F tmp.access-log
然后当我完成后,如果我不需要该tmp文件,我就删除它。