Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [tail]

Watching updates at the end of a file, with or without the tail utility

1
vote
1answer
33 views

How to test whether my tail is posixly correct?

I'm having problems with a vim interface for the theorem prover HOL: https://github.com/HOL-Theorem-Prover/HOL/tree/master/tools/vim I run it on MobaXterm, a cygwin-based system, and vim is freezing ...
0
votes
2answers
55 views

How to insert a line in a file after certain bytes

Let's say I have a large file (several gigs) with n lines in it. I would like to add/insert a line after k bytes offset, from the beginning of the file, then what would be the fastest way to achieve ...
0
votes
2answers
29 views

How can use tail for notifications above 0.99% loadav?

#!/bin/bash ( tail -f -n0 /proc/loadavg 2> /dev/null & ) | grep -q "^[1-9]" echo 'The millenium crystals are gunna blow!' I though I was being clever and that would work. It just hangs and ...
0
votes
1answer
32 views

run command in script after an ssh

In my script I need to access a remote server using ssh. On the remote I want to gather some data from log files. I have my script set up and the code works, but my problem is when I run the script it ...
0
votes
0answers
40 views

How to write Docker logs to a file in real time (à la `tail -f`)

I docker that output logs stdout stderr, which can be viewed using: docker logs -f $LOGS_CONTAINER_ID I also added 'sed', which puts the container id on each line: docker logs -f $LOGS_CONTAINER_ID ...
0
votes
1answer
50 views

Tail a file while it's open for writing

I'm writing continuously to a file, and I want to tail it from another shell. But it seems that as long as the file is open for writing, tail -f filename can't show all the new lines until the file ...
1
vote
0answers
36 views

tail reopen file when directory changes

I've got a symlink pointing to the "latest" directory, and I want to tail a file in the latest directory, even if the symlink changes to a newly created directory. I often use tail -F for files and ...
1
vote
2answers
156 views

Slicing the output of grep in bash

I'm trying to read a line of text in bash using grep, piped to tail to get the final line of the file, and then slice the first three "words" (i.e. dividing them using space) of that line as elements ...
4
votes
0answers
29 views

Tailing file using less +F/shift-F, turn off line buffering?

When using tail -f, it prints each character as it is written to the file, but less +F won't print until it sees a linefeed. And if the data being written to the file does not contain linefeeds, must ...
2
votes
2answers
94 views

Why xargs can't work with tail -f?

I want tail -f /var/log/syslog | grep it with pattern "arpwatch" and send every line to myself via jabber: xmpp username@jabber.server using xargs tail -f /var/log/syslog | grep arpwatch | xargs ...
0
votes
2answers
47 views

alternative to `tail -f <filename>` allowing printing continuous stream from multiple files in multiple folders under the same parent folder [duplicate]

As far as I know, tail -f <filename> allows to continuously print newly appended data from one single file. What if I need to get content from multiple files located in multiple folders under ...
0
votes
1answer
27 views

daemon version of tail -f dir1/app.*.log.* dir2/app.*.log.*

I need to code a daemon that track the content of log-files on multiple hosts. The "log drives" (hosts are Windows Servers) are all mounted in a single Linux host. The tricky part is that the log-...
0
votes
0answers
166 views

tail: error writing 'standard output': Broken pipe

I tried to use some scripts which use tail commands on Debian stretch but I got tail: error writing 'standard output': Broken pipe. Does Debian handle tail and pipe syntax differently? Thank you in ...
0
votes
0answers
54 views

Tail with case statement is not working properly [duplicate]

I want to monitor the logs continuously and echo the output if keyword appears then continues the monitoring!! My question is how to perform the below operation tail the logs if keyword[down] ...
1
vote
0answers
80 views

tail -F is not working with while and case statement [closed]

I want to monitor the logs continously and echo the output if keyword appears then continues the monitoring!! My question is how to perform the below operation Tail the logs. If keyword[down] ...
2
votes
1answer
791 views

Hex dump only the beginning and the end of a file with xxd [duplicate]

I am looking for a command to display three .png files using xxd, displaying the first two and last two lines of the hexadecimal for each. I have used the command below to display one file at a time ...
0
votes
3answers
84 views

How to make tail to automatically reconnect to a log file that was deleted and recreated together with its parent directory

I am using tail with option --follow=name to watch my log files in my servicemix instance (path = ${smx_home}/data/log/servicemix.log). ServiceMix have a 'nice' feature to restart clean with ...
24
votes
2answers
2k views

'tail -f' for a specific amount of time [duplicate]

I need to run tail -f against a log file, but only for specific amount of time, for example 20 seconds, and then exit. What would be an elegant way to achieve this?
3
votes
2answers
101 views

Concatenate multiple zipped files, skipping header lines in all but the first file

I have a collection of gzipped files that I want to combine into a single file. They each have identical format. I want to keep the header information from only the first file and skip it in the ...
4
votes
2answers
160 views

No log content with tail but when terminating a process I see content with less

Basically, I am running: nohup ./executable &> /tmp/out.log & In order to make sure the process is running I ran the command: tail -f /tmp/out.log But the only thing I can get from tail ...
1
vote
0answers
211 views

How to tail and grep log file, combine into a single line and pass as argument to another command

Using the following command, I managed to fetch error messages below (it's 3 lines). $ tail -f -n 0 error.log | grep -A2 --line-buffered "Internal server error" ! @79884flo2 - Internal server ...
1
vote
2answers
61 views

Stream contents of directory instead of reading all items [closed]

Is there a unix command I can use to stream the items/contents of a directory? Using Node.js, we can read everything into memory with: fs.readdir(dir, (err, items) => {}); but I am looking to ...
1
vote
2answers
356 views

Continuously print last line of file to single line on terminal

How can I continuously print the last line of a file to a single line in the terminal? The following works, but has a high performance hit. while true; do tail -1 /tmp/somelog | tr "\012" "\015"; ...
0
votes
1answer
60 views

Why `tail -f data_log | grep keyword` within tmux session could lead to hard disk exhaustion?

The scene is like, yesterday I need to check some api bug. So I logged into the log server. I opened up a tmux session, so I can reconnect to my work later. I typed in tail -f data_log | grep keyword ...
1
vote
2answers
295 views

How to continuously tail a log, find all files (sed), and display (cat) the found files

How to I continuously tail -f a log, find all files (sed), and display (cat) the found files example data in audit logs. tail -f /var/log/httpd/modsec_audit.log | sed 's/[^\/]*/\./;s/].*$//g' ...
7
votes
5answers
2k views

Display only the penultimate (second last) row of a text [duplicate]

I have a poem with an unknown number of rows and I want to display only the penultimate one. What command should I use?
10
votes
2answers
396 views

Read logs from one process during run of some command

I have some service which produces logs in the file logs.log. I have some other command which interacts with this service. Let's say it is some foo.sh. What I need, is to cut and save logs from logs....
0
votes
4answers
425 views

Quick head/tail command question

This is the output from the file I'm using: aaaaa bbbbb ccccc ddddd eeeee fffff ggggg hhhhh iiiii jjjjj I know using tail -n 5 filename will display this: fffff ggggg hhhhh iiiii jjjjj How do I ...
-1
votes
1answer
204 views

tail and bash: different output when same is expected

I'm trying to sort my logs and found that single digit dates were cut incorrectly. Now I want to either add a 0, or remove the extra space. Prior to that, I wanted to see how to get the correct lines ...
1
vote
0answers
212 views

How to tail -f until a text is found and no more lines are printed? [duplicate]

I'd like to integrate the following, similar, question: `tail -f` until text is seen The proposed solution consists in using the sed command which, when the test is found, exits. Tail will then fail ...
2
votes
1answer
94 views

How to restrict interrupt signal to just the child process?

I have a bunch of log files and I want to do a tail -f on them in a loop such that when I press Ctrl-C, the current tail -f gets killed and I proceed to the next log file: for log in *.log; do ...
13
votes
3answers
1k views

tail -f, insert line break after log is idle for 3 seconds?

When doing a tail -f error.log, how to insert programmatically a line break after nothing has been appened to the file for 3 seconds ? (obviously, once one line break has been added, no other line ...
1
vote
1answer
166 views

tail -f all files in a “living directory” [duplicate]

I am working with a directory where logs are constantly created. I use tail -f * in bash to view all the log entrys in the dir. However, when new files are created while the tail is running, the new ...
2
votes
2answers
558 views

How to get colored output with tail command [duplicate]

Below is the tail statement: tail -4 FDECMP1_$$.log I need to print the last 4 lines of file FDECMP1_$$.log in Red.
3
votes
1answer
111 views

How a tail a file that is given as the output of a find function? [closed]

I'm brand new in Unix environment. I would like to monitor the output of a calculation on a cluster with a function. I have tried this function I have put inside my .bashrc file under the alias ...
1
vote
3answers
323 views

Multiple Grep Searches

I wish to get the last line of a log file that matches a test string and output to another log file. I need to test for a number of different text strings and depending on the output send to a ...
7
votes
2answers
1k views

What logic does the command “exec tail -n +3 $0” from grub2 config have?

Creating custom menu entry, got stuck on this command: exec tail -n +3 $0 Tried it in terminal, got weird result, cannot understand, what this command exactly does and why grub needs it. Could you ...
3
votes
1answer
2k views

“tail -f | grep error” with while loop is not working

The below command is not giving any result. I want to grep the error line from the file and insert into table. Command which is not working: tail -f logfile.log | grep ERROR|while read msg; do psql ...
0
votes
1answer
588 views

tail not working on mac terminal

Due to my lack of experience with script language, (shame for a Mac user) I have referred to several sources: link seemed resolved with ls *.extension | xargs -n 1 tail -n +2 This didn't for me, ...
4
votes
1answer
628 views

make tail -f exit on a broken pipe

I want to watch a file until a bit of text appears I found this answer: `tail -f` until text is seen but when I tried it on ubuntu, it doesn't exit: $ echo one > test.txt $ echo two >> ...
0
votes
3answers
63 views

How to fillter and view only a substring of ip table Logs with tailf and sed?

one line of iptable log is: Jan 1 21:41:19 x kernel: [838760.885218] IPTables-Dropped: IN=eth0 OUT= MAC=x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:00:x:00:00:x:00:x:x:x:x SRC=x.x.x.x DST=x.x.x.x LEN=70 TOS=...
0
votes
0answers
89 views

How to use command on output of processed tail -f? [duplicate]

So I monitor some logs (/var/log/apache2/error.log) with the command tail -f, and only print the errors (grep ':error'). I combined both of these in a script (namely, watch_error_log.) NB: I am part ...
0
votes
0answers
27 views

tail/head piping remove newlines [duplicate]

If have the following file /tmp/f1.txt file coming from the stdout redirection of the result of a PostgreSQL bash script execution : id ----- 517 518 519 520 521 522 (6 rows) INSERT 0 6 I ...
3
votes
2answers
1k views

tail -f, but when the file is deleted and re-created (not appended)

I'm trying to watch for any new output of a log file. Another script (not under my control) is deleting the file then creating a new one with the same name. Using tail -f doesn't work because the file ...
3
votes
1answer
61 views

How to periodically watch a file from a list of files

I've a running java project that prints it's output to a file named in according to the current time: 03:45 ==> 03.out 13:24 ==> 13.out etc... Now I want to watch tail of the file currently ...
0
votes
1answer
112 views

Using mouse scroll with Multitail

Is there any way to use the mouse wheel, or the terminal window slide bar, to look through a multitail log? Ideally multitail would work almost exactly like tail (except with the obvious coloring).
2
votes
2answers
83 views

display only portions of lines from live log file

We have a log file that I often follow live with tail and use grep to filter for the lines I'm interested in. However, the lines contain a lot of data I'm not always interested in but they have been ...
14
votes
1answer
1k views

Why does piping to 'tail' change the contents of a line?

When I view the result of a SELECT with MySQL Workbench, it's correct with one single \ max@host 10:13:58: ~$ mysql -h db-master.domain.local -uuser -ppw db -e ' > SELECT > ...
1
vote
1answer
69 views

Is there a way to disable the delay of less +F?

Running less +F file is very convenient because you can switch in and out of forward-forever mode with Ctrl-C and ⇧-F respectively. Unfortunately new lines appear with a delay, which is very ...
-1
votes
2answers
178 views

How to tail multiple files without empty lines?

As I've noticed, a command such as tail -n +5 a b prints its output in a format like this: ==>a<== contents of a from line 5 to $EOF (including line 5) ==>b<== contents of b from line ...