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
18 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
29 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
35 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
33 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
48 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
251 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 ...
51
votes
6answers
66k 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 ...
253
votes
19answers
176k 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
66 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
66 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
277 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
35k 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
658 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
869 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
21 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
97 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
690 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 ...
18
votes
4answers
33k 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
50 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
10k 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
213 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
41 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
205 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
104 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 ...
3
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
404 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
259 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
45 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
833 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
145 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
33k 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
57 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
29 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-...
10
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 ...
2
votes
1answer
94 views

Command modification

I'm using the following command to get the highest number of requests per second in a log file and it works well. grep "2017-02-22" "LogFile.log" | cut -c1-20 | uniq -c | sort -n | tail -n1 Now I ...
2
votes
3answers
318 views

Using pipes to list the first two and last two users on the system?

I have to use the who command to display who's online, then use pipes to display the first and last 2 users online. the only thing I know how to do is something like: who | head -5 | tail -2 . ...
4
votes
2answers
832 views

bash syntax - wrapping command inside sudo :: tail logs until string found with timeout using Terraform

Goal: using sudo execute a one line cmd to tail a log until a string is found and then exit 0. If the string is not found within a given timeout, exit anything but 0. Attempted Solution 1: ...
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
86 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] ...
0
votes
3answers
93 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 ...
2
votes
1answer
1k 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 ...