bat
bat copied to clipboard
`tail -f | grep | bat` fails (on Linux)
When working with logs, it's common to tail -f
a log to view it in realtime, and then pipe it to grep
for interesting data.
bat
fails to produce output when feed such a pipe.
Steps to reproduce the bug
- Have a long enough log with a common pattern appearing from time to time.
/var/log/apt/history.log
of a Debian system is used in this example, but any log will do. - Find a pattern and allow enough lines for
tail
to have it:tail -n 1000 -f /var/log/apt/history.log | grep Date
should give several lines of output. - Pipe the above output to
bat
, i.e.:tail -n 1000 -f /var/log/apt/history.log | grep Date | bat --paging=never
.
Result The output is empty.
Expected result The output contains the lines observed on step 2.
More investigation
- If no
-f
option is given totail
,bat
works as expected. (tail -n 1000 /var/log/apt/history.log | grep Date | bat --paging=never
produces the expected output) - If no
grep
is done,bat
works as expected. (tail -n 1000 -f /var/log/apt/history.log | bat --paging=never
produces the expected output)
How did you install bat
?
Official deb
repo.
bat version and environment
Software version
bat 0.21.0 (405e5f7)
Operating system
Linux 5.10.0-14-amd64
Command-line
bat --diagnostic
Environment variables
SHELL=/bin/bash
PAGER=<not set>
LESS=<not set>
LANG=ru_RU.UTF-8
LC_ALL=<not set>
BAT_PAGER=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=truecolor
NO_COLOR=<not set>
MANPAGER=<not set>
Config file
Could not read contents of '/home/evgeny/.config/bat/config': No such file or directory (os error 2).
Custom assets metadata
Could not read contents of '/home/evgeny/.cache/bat/metadata.yaml': No such file or directory (os error 2).
Custom assets
'/home/evgeny/.cache/bat' not found
Compile time information
- Profile: release
- Target triple: x86_64-unknown-linux-gnu
- Family: unix
- OS: linux
- Architecture: x86_64
- Pointer width: 64
- Endian: little
- CPU features: fxsr,sse,sse2
- Host: x86_64-unknown-linux-gnu
Less version
> less --version
less 551 (GNU regular expressions)
Copyright (C) 1984-2019 Mark Nudelman
less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: http://www.greenwoodsoftware.com/less