Questions tagged [tail]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
28 views

how to mimic “tail -f … | grep …” using less?

When using tail -f some/filename, it waits for more to be appended to the file. Just like less +F .... However if I have a pipeline such as tail -f some/filename | ... then the less +F ... | ... does ...
2
votes
3answers
2k views

Tail -f breaks when file truncated

I am using tail -f (in Terminal on Mac OS X el capitan) to view the live changes to my file (the results of pulling data from a database using a PERL script). However, sometimes, the Perl script will ...
0
votes
1answer
71 views

How to detect and examine recent changes in a text file?

How to get last changes in text file on Linux? Example: text1 text2 text3 and then a programme adds another line to the text file: demo1 If the last change was the addition of demo1, print in ...
3
votes
3answers
72 views

tail a log util keywords found or timeout

I'm using a special way that can let me visit google. It is very different in the page now... So I can edit the question and comment the answers normally. I deleted more early discussions and go to ...
5
votes
2answers
77 views

Linux: write tail -f output, plus comments, to a separate text file

The command tail -f command is great for tracing, and in terminal it's very helpful to be able to, for example, hit enter, and type a comment like -- after xyz change... -- For record purposes, I ...
36
votes
8answers
20k views

How do I make Vim behave like “tail -f”?

I would like to know if there is a way to make Vim behave like tail -f. Even the best Vim plugin I've found so far doesn't do what I expect. I really want to see the file update in real-time. Even I'...
4
votes
4answers
2k views

tail -f a file for 10 minutes / until N matching lines?

I've got a log file that I process as follows: grep pattern /var/log/whatever.log | \ cut ... | sort | uniq -c | sort -rn | \ etc.... However, the log file is quite big, and records events ...
1
vote
1answer
21 views

tail latest data only, not the previous one

I notice that when I use tail -F, I'm still getting a log generated a few minutes ago. Current date and time user@svr01:~$ date Wed Jun 19 00:39:52 +08 2019 tail -F shows data a few minutes before ...
0
votes
1answer
33 views

“tail” Is Returning the Wrong Requested Number Lines

I'm trying to use the following approach to subset the output of a manual: man dig | nl | tail -n +389 | head -n 6 However, the output starts at line 304, not line 389. Doing some research, it seems ...
1
vote
1answer
47 views

How to cat named pipe without waiting

If there is nothing in a named pipe and I do: cat my_named_pipe it will wait until data arrives. Is there a flag I can use to exit immediately if there is no data to be read? Or perhaps a command ...
0
votes
1answer
58 views

Display line number in head and tail command like `cat -n`

cat without -n user@linux:~$ cat /etc/sysctl.conf | head -4 # # /etc/sysctl.conf - Configuration file for setting system variables # See /etc/sysctl.d/ for additional system variables. # See sysctl....
0
votes
1answer
59 views

Writing a Shell script to tail and gzip a log file

I'm trying to make a script that can tail log files from a remote server to my local directory. tail -F is what I'm using but after piping it with gzip, nothing happens although a local copy of the ...
0
votes
1answer
270 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 ...
53
votes
6answers
67k views

Best way to follow a log and execute a command when some text appears in the log

I have a server log that outputs a specific line of text into its log file when the server is up. I want to execute a command once the server is up, and hence do something like the following: tail -f ...
257
votes
19answers
178k views

How to have tail -f show colored output

I'd like to be able to tail the output of a server log file that has messages like: INFO SEVERE etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I setup ...
1
vote
1answer
73 views

Why do I need 'exec' if 'while read' can open a 'File Descriptor'

I want to read a file line by line using bash, tail and using a diferent file descriptor. all the guides use this method: method 1: echo 1111111 > z.txt exec {newFD}< <(tail -f -c +0 "z.txt"...
0
votes
2answers
69 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
1answer
278 views

Stop tailing log [closed]

I have a problem, I accidentally did tail -f on a log, but now I cant quit! - Its the anaconda log during a redhat install. Control-C doesn't seem to work, I guess due to it saying sh: no job control ...
0
votes
2answers
38 views

How to extract lines knowing start and end lines

I have a file with 1 million lines. I want to extract lines from line 10001 to 500000 How to do this?
54
votes
9answers
36k views

How to obtain inverse behavior for `tail` and `head`?

Is there a way to head/tail a document and get the reverse output; because you don't know how many lines there are in a document? I.e. I just want to get everything but the first 2 lines of foo.txt ...
2
votes
2answers
697 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.
8
votes
3answers
888 views

Echoing a tail command produces unexpected output?

This command, when run alone, produces the expected result (the last line of the crontab): tail -n 1 /etc/crontab However, when I run it as part of an echo command to send the result to a file, it ...
0
votes
1answer
1k views

tail-ing a filename that is a date [duplicate]

I am creating a logfile from kermit named the current date (which is in the format of DD MMM YYYY - which can not be changed AFAIK), and using the file name as today's date. I then have a Bash script ...
0
votes
0answers
23 views

Monitor Apache Selectively

I am working to parse apache logs in Common Format in realtime so that I monitor them while I work. "tail -F /var/log/apache2/access.log" works but provides more than I need. "awk '{print $1 " " $2 " "...
0
votes
1answer
101 views

How to prevent/keep tail from replacing \r by \n

When I play a video with mpv in the backgroud, I get this : $ tail -f nohup.out Playing: https://www.facebook.com/TBN/videos/1580372468665943/ (+) Video --vid=1 (*) (h264 1266x720 30.000fps) (+) ...
6
votes
3answers
691 views

Using “tail” to follow a file without displaying the most recent lines

I would like use a program like tail to follow a file as it's being written to, but not display the most recent lines. For instance, when following a new file, no text will be displayed while the ...
21
votes
4answers
35k views

Combining tail && journalctl

I'm tailing logs of my own app and postgres. tail -f /tmp/myapp.log /var/log/postgresql/postgresql.main.log I need to include pgpool's logs. It used to be syslog but now it is in journalctl. Is ...
1
vote
1answer
51 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 ...
8
votes
4answers
11k views

What's an alternative to tail -f that has convenient scrolling? [duplicate]

I'm usually inside GNU Screen or tmux, and that doesn't give me great scrolling functionality. Is there an alternative to tail -f that allows me to quickly scroll up? A tool that is like most is to ...
0
votes
1answer
218 views

Need to grep for specific lines from ongoing log and save it in some file

There is just one log, which will have info on certain devices, that i am upgrading. I use "tailf log" to monitor the log. Now, say, I am upgrading 10 devices, the log will go on populating lines ...
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
43 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
362 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
151 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 ...
3
votes
2answers
2k views

multitail - custom config (multitail.conf) location

Is it possible to provide a custom location for multitail.conf, or are my only options /etc/multiltail.conf or ~/multitail.conf? I'd like to provide a specific config file that has regexes specific ...
1
vote
0answers
40 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 ...
4
votes
2answers
2k views

Send EOF to named pipe - cleaning up / drying up fifo

If I have some random processes reading from a named pipe: tail -f MYNAMEDPIPED cat MYNAMEDPIPE | someOtherProc Elsewhere, I have a handle on MYNAMEDPIPED by name. is there a safe and clean way to ...
10
votes
2answers
414 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....
1
vote
2answers
304 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 ...
1
vote
2answers
6k views

Piping the result of ls to tail [duplicate]

I have a directory with a bunch of log files. Something like this: data170213.log data170214.log data170215.log data170216.log I'm interested in looking at the last entries of the most recent file ...
4
votes
0answers
50 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 ...
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 ...
23
votes
9answers
53k views

Command to display first few and last few lines of a file

I have a file with many rows, and each row has a timestamp at the starting, like [Thread-3] (21/09/12 06:17:38:672) logged message from code..... So, I frequently check 2 things from this log file. ...
0
votes
1answer
862 views

Running multiple commands for multiple files on one line [duplicate]

I'm attempting to run multiple commands on the same line for multiple files. I have little experience with Linux and I've run into an issue with this command: tail -n +3 "/usr/local/tmp/csce215/...
2
votes
2answers
161 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 ...
35
votes
7answers
34k views

How to tail multiple files using tail -0f in Linux/AIX

I tried tailing two files using the option: tail -0f file1.log -0f file2.log In Linux I see an error "tail : can process only one file at a time". In AIX I see the error as "Invalid options". This ...
0
votes
2answers
59 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
31 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-...
11
votes
3answers
11k views

Negative arguments to head / tail

Variants of this question have certainly been asked several times in different places, but I am trying to remove the last M lines from a file without luck. The second most voted answer in this ...
0
votes
3answers
4k views

Using the tr command

Assume that the file ft has 25 lines of text. Explain the command: tail -15 ft | tr "a" "A" > ft and tell me how many lines the file ft has after the execution of the command. I understand that ...