Score:1

How to tail multiple gz files

id flag

To tail multiple log files, I use:

tail /path/to/logs/*.log

To tail a zipped log file:

zcat /path/to/mylog.1.gz | tail

But I'd like to tail multiple zipped log files since the output of the following will not be readable:

tail /path/to/logs/*.gz
Score:1
jp flag

With reading zcat's output for each single filename(No globbing) from a named pipe using bash's process substitution syntax ... e.g. like so:

tail <(zcat /path/to/mylog.1.gz) <(zcat /path/to/mylog.2.gz) ...

or with shell's filename globbing using a for loop ... e.g. like so:

for f in /path/to/logs/*.gz; do echo "====> $f"; zcat "$f" | tail; done
Score:0
jp flag
knb

Does this work for you?

ls -1 /path/to/logs/*.log.gz | xargs -i bash -c "zgrep -H . {} | tail -2 "

hr flag
I'd suggest something more like `printf '%s\0' /var/log/*.gz | xargs -r0 -I {} sh -c 'zgrep -H . "$1" | tail -n 2' sh {}` or (borrowing [Raffa's idea](https://askubuntu.com/a/1451911/178692) to make a `tail`-like multi-file header) `printf '%s\0' /var/log/*.gz | xargs -r0 -I {} sh -c 'printf "====> %s\n" "$1"; zcat "$1" | tail -n 2' sh {}`
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.