Questions tagged [tail]
Watching updates at the end of a file, with or without the tail utility
432 questions
0
votes
0
answers
37
views
Is there anything like `tail -f` but that can follow multiple files and show which file each line came from? [duplicate]
I'm trying to monitor multiple log files simultaneously, but when I use:
tail -f /var/log/app1.log /var/log/app2.log
I get mixed output and can't easily tell which file each line originated from. What ...
8
votes
1
answer
976
views
What is the `-0` flag in `tail`? [duplicate]
The Logstash documentation said about the input file plugin that it
Stream events from files, normally by tailing them in a manner similar to tail -0F but optionally reading them from the beginning.
...
0
votes
1
answer
109
views
Does "less" have "--retry" option like "tail"?
I'm using less to continuously trace Squid log file (as well as UFW log) with this command:
less --follow-name -K +F /var/log/squid/access.log
And at the time of rotation of Squid log less quits. I ...
0
votes
1
answer
55
views
Run a few identical process and then kill one of them
Problem:
Need to run several process, especially it will be “tail -f log.log >> wrile_log.log” proces to collect log.
Commands can be run at the different time for same log file. This is not ...
1
vote
3
answers
356
views
How to tail continuously a log file that is being deleted and recreated?
I need to extract information from a log file that is deleted and recreated every time a program runs. After detecting that the file exists (again), I would like to tail it for a certain regexp.
The ...
16
votes
5
answers
13k
views
How do I read the last lines of a huge log file?
I have a log of 55GB in size.
I tried:
cat logfile.log | tail
But this approach takes a lot of time. Is there any way to read huge files faster or any other approach?
1
vote
0
answers
37
views
pfSense (FreeBSD) - tail -f not showing entire log when filtering with cut or sed [duplicate]
I have a strange problem when trying to display logs on pfSense (and I can reproduce the same problem on Ubuntu server also).
The problem is this (with examples):
I'm trying to display a running dhcp ...
-1
votes
2
answers
88
views
Linux "watch" command showing last 30 lines of nft list ruleset [duplicate]
I want to constantly see last 30 lines of code "nfc list ruleset" in Debian Bash. Something like this:
watch -n 1 nft list ruleset | tail -n 30
But above code doesn't show last 30 lines of &...
3
votes
2
answers
551
views
Tail -f | sed. Modify text for color
I am modifying the text following tail -f.
I have the following program that monitors a file:
tail -vf -c5 /tmp/index \
| cat -n \
| ...
1
vote
1
answer
85
views
How to follow constantly a keyword in multiple files and include filename beginning of each reported line
tail -f a/b/c.log d/e/f.log
logs like this:
==> a/b/c.log <==
xxx
yyy
Exception happened 1
zzz
==> d/e/f.log <==
rrr
Exception happened 2
sss
How to change command so that the lines ...
1
vote
2
answers
3k
views
Head/Tail command to grab multiple sets of lines
I have to grab the first two lines, the lines 43 and 44, and the last 2 lines from a file in one conduct of commands.
Is there away to print those while only using head, tail and pipe commands AND ...
0
votes
2
answers
315
views
Side by side output from two `tail -f` commands
I have two scripts emitting single string to log files periodically that I need to tail -f and combine side by side for which I am using paste. This works but I am unable to pipe the output to another ...
0
votes
1
answer
908
views
Continuously display last line of command output without clearing the screen
I want to print only the last line of the output of a command on the same line continuously without clearing the screen. This would be part of another function. Let's say my script has the following ...
0
votes
1
answer
202
views
Sleep vs tail to wait on process
Currently I do:
while [ -d "/proc/$PID" ]; do
sleep 1
done
To wait for a process to exit. If I would replace it with:
tail --pid=$PID -f /dev/null
Would that be more efficient for the ...
2
votes
6
answers
264
views
Only pipe output if at least n lines
I often want to grep output from processes that include a few header lines. But if grep would remove all actual content lines, I don't want to display the header lines. For this to work I would need a ...
2
votes
4
answers
2k
views
Grep and find to get the last match in multiple files [duplicate]
Assume two files with the following content:
$ cat ttest1.txt
x = 1
x = 3
y = 5
$ cat ttest2.txt
x = 4
x = 10
y = 3
I would like to recursively grep the files for x and print the last instance in ...
0
votes
1
answer
351
views
How to exit a FOR loop on detecton of "error" stream using TAIL
I have a "for" loop which passes the results to a file called "results"
Occasionally an error stream is detected and the loop continues trying within the loop for a number of times ...
12
votes
2
answers
2k
views
Why can't I do two greps after a tail?
I'm able to run this command successfully:
tail -f my_file.txt | grep foo
It shows only the lines with the string foo, and it keeps showing them.
But when I run this command:
tail -f my_file.txt | ...
1
vote
1
answer
181
views
"tail -f", but on a file which gets rewritten (downloaded) again and again without outputting then content over and over again?
I've got log files which get downloaded via cron job. If a file is updated on the remote location, the local copy gets rewritten from the beginning even if only data has been appended.
Tools like tail ...
0
votes
1
answer
127
views
How to follow logs while avoiding line wrapping w/ horizontal scroll enabled?
In the terminal, if I don't want to have logs of a program wrap, I can pipe those to less -S.
However, horizontal scroll with keyboard doesn't work unless I Ctrl+C, and after that, I don't know how to ...
1
vote
0
answers
24
views
Weird grep behavior with invalid UTF8 input [duplicate]
I need to monitor a log file which sometimes contains invalid UTF8 characters.
Like this:
shaozr@fedora utf8-cut (bear_from_3.1.18) $ tail -F a.txt
a我々はMozartが好きです。
a我々はBachも好きです。
a▒▒▒々はMozartが好きです。
a▒...
3
votes
3
answers
310
views
How to get around issue with `tail -f` not emitting EOF and make it works with tools like `csvtool`?
I basically want to do this:
tail -f trades.csv | csvtool readable -
I want to read a CSV file in a readable format using csvtool and I want to keep watching it.
I think that command doesn't work ...
1
vote
0
answers
20
views
What's wrong with my log file generation?
I'd like to capture and filter the logs from my ESP32 peripheral from the serial port and generate a new log file with the selected line.
I do as follows:
$ (((stty speed 115200 && cat) </...
1
vote
2
answers
64
views
How to terminate _follow_ mode in **less** (`+F`) from pipe?
Assuming the following dummy command in bash:
### dummy long_operation_cmd function, for easy reproduction:
function long_operation_cmd() {
echo "operation 1"
sleep 5
echo "...
1
vote
3
answers
1k
views
How to suffix or prefix each line coming from tail command
I have a file and I am running a tail command on this file like this
tail -n+1 -F "./log/catalina.log"
I want to suffix or prefix another string to each line coming out of this file, which ...