[tip] lnav recurse into /var/log excluding a directory

CaffeineAddict

Well-Known Member
Joined
Jan 21, 2024
Messages
2,506
Reaction score
2,050
Credits
20,296
lnav is awesome live log reader, but if your distro is providing you with version older than v0.12 (e.g. Debian) then using the -r flag to recurse into /var/log will not work well because version older than 0.12 will stuck reading /var/log/journal directory due to a bug.

Ideally you use lnav to recurse into /var/log like this:
Bash:
sudo lnav -r /var/log

The above will not work because it will stuck recursing into /var/log/journal directory.
The objective is to exclude /var/log/journal directory from command line, but lnav does not provide us with such option, so now what?

Here is my solution how to recurse and exclude /var/log/journal directory:

Bash:
sudo lnav -r $(ls /var/log/*/ -d | grep -v journal) $(find /var/log -maxdepth 1 -type f)

I hope you find this command useful, if so add it to your ~/.bash_aliases like this:
Bash:
alias lnav-all='sudo lnav -r $(ls /var/log/*/ -d | grep -v journal) $(find /var/log -maxdepth 1 -type f)'

Then in new terminal simply run lnav-all

---

Irrespective of lnav bug, this command is useful to selectively exclude directories even if you use latest version of lnav because there is no option to exclude directories with -r recurse flag.
 


Members online


Top