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

0
votes
2answers
60 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
271 views

Stop tailing log [on hold]

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
28 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?
-2
votes
1answer
52 views

Can I combine the tail and gzip commands inside a function? [closed]

I'm currently learning UNIX commands as part of my internship. Is there a way to combine these two commands-> (tailing log files then zips it using gzip)? My script is posted below: #!/bin/sh # ...
52
votes
9answers
34k 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
594 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.
7
votes
3answers
833 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 ...
250
votes
19answers
171k 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 ...
0
votes
0answers
20 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
89 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
673 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 ...
14
votes
4answers
30k 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
votes
0answers
38 views

grep and tail multiple files

I have multiple calculations running in various folders and sub folders and would like to see the relevant output for all files with the word 'CONVERGED' in the last 200 lines of the file. The word ...
1
vote
1answer
42 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
212 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
38 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
64 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
61 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
38 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
1k 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
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....
1
vote
2answers
177 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
5k 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
32 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
52k 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
785 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
116 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 ...
34
votes
7answers
32k 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
50 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-...
9
votes
3answers
10k 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
89 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
281 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
799 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
194 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
85 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
86 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
865 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 ...
53
votes
2answers
31k views

Observe multiple log files in one output

Is there an easy way to do something like tail -f mylogfile but to have the changes of more than one file displayed (maybe with the file name added as prefix to each line)? Or maybe a GUI tool? I am ...
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 ...
8
votes
3answers
18k views

Suppress 'file truncated' messages when using tail

I'm tailing a log file using tail -f messages.log and this is part of the output: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eget tellus sit amet odio porttitor rhoncus. Donec ...
20
votes
4answers
15k views

How to quit `tail -f` mode without using `Ctrl+c`?

When I do tail -f filename, how to quit the mode without use Ctrl+c to kill the process? What I want is a normal way to quit, like q in top. I am just curious about the question, because I feel ...
19
votes
7answers
19k views

`tail -f` until text is seen

I've got a CI server with a command-line interface that allows me to remotely kick-off a job (jenkins CI server and the jenkins-cli.jar tool). After I kick the job off I tail -f the log (sorry for ...