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
1answer
1k 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, ...
1
vote
2answers
191 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).
149
votes
7answers
279k views

cat line X to line Y on a huge file

Say I have a huge text file (>2GB) and I just want to cat the lines X to Y (e.g. 57890000 to 57890010). From what I understand I can do this by piping head into tail or viceversa, i.e. head -A /...
0
votes
4answers
58 views

How to 'tail' a logfile, X lines at a time

I have a logfile that is generating hundreds of lines per second – say, 12 specific lines, 16× per sec. I want to run either a command-line or a shell script that can display this logfile neatly in ...
14
votes
1answer
2k views

Why does piping `mysql` to 'tail' change the output format?

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 > ...
3
votes
1answer
7k views

Bash tail -f with while-read and pipe hangs

In Bash, piping tail -f to a read loop blocks indefinitely. while read LINE0 do echo "${LINE0}"; done < <( tail -n 3 -f /tmp/file0.txt | grep '.*' ) # hangs Remove the -f or | grep '.*...
2
votes
2answers
59 views

Display last n lines of the output of a command

I am trying to run docker build command. I wanted to see only last 'n' lines of the output continuously. For example, usual docker build command give me something like: Building myimage Step 1/15 : ...
0
votes
1answer
36 views

tail -f -n 1 returns all content of the file

I have a text.txt file in Ubuntu. I want to watch the file with tail for grabbing the last content of the file. tail -f text.txt this command returns all of the content. So I changed it to : tail -f -...
0
votes
2answers
35 views

Using tail -f together with sed and xargs

Suppose I have the following process to write a number + single quote to the file /tmp/test every second: for i in {1..1000} ; do echo $i\' ; sleep 1 ; done > /tmp/test I then want to use tail -f ...
3
votes
0answers
80 views

Why does 'tail -c 10K' cause it to read an entire 16GB flash drive?

To view the last 10K of a 128GB internal SSD I used: sudo tail -c 10K /dev/sda | xxd This worked as expected and immediately output the data. However when I try to view the last 10K of a 16GB USB ...
0
votes
1answer
18 views

Using Tail on a process causes character input delay & disruption [duplicate]

I was referring to this question to see if it is possible to spy on another running process' stdout. One answer suggests using tail -f /proc/<PID>/fd/1 to do so. So I opened two terminal ...
280
votes
20answers
205k 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
0answers
32 views

Inconsistent behaviour when piping output of Tail into Xargs through an editing command

I'm giving in to asking the SE spirits for assistance. I will expand in detail below, but I've boiled the inconsistency down to these 3 lines. I am trying to grep a string in between single quotes (...
0
votes
1answer
1k views

live tail (tail -f) of file being grepped

i can do tail -f -n20 <file> to see the last 20 lines of the file, live. If i want to grep something, tail -f <file> | grep <pattern>, it will still be live, but will only grep ...
1
vote
2answers
57 views

How can I tail multiple files and pipe their output to an SSH connection

We are currently running a command on a Linux box that we have little control over. The command tails a log file, piping the results to an outbound SSH connection to our server, redirecting the output ...
0
votes
0answers
35 views

How do I 'tail -f' to a file, while also executing a script utilising that file indefinitely?

I am so close to getting it, but fear I have spent too long looking at this and am getting lost as to how to accomplish what I want. What I am trying to do: Take the access log from my server, parse ...
1
vote
2answers
66 views

tail command does not display last line

I am using the following command to read the last line every time the file changes. tail -f -n1 Entrie.txt It happens that the first line written shows it without problems, but later when I write ...
0
votes
1answer
1k 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
23 views

Any way to tell where log output is coming from?

On a unix system, I have a file in /logs which is being written to constantly by multiple sources. Is there a way, maybe with tail(?), to determine what processes are writing to this output?
1
vote
1answer
45 views

Is there a command that combines `tee` and `grep` such that in a pipeline the tee part can direct matches to a file?

I'm looking to pull multiple pieces from a file, or at least watch for pieces in a log file if they should occur, but I don't want to setup multiple tail | grep sessions. Instead I'd like to just ...
0
votes
0answers
20 views

given `logger -t specificUser` how do filter tail by that tag? (tail -f ??? specificUser)

if i'm tagging my logs with -t, how do i filter my log searches for that specific tag? given: logger -t specificUser show it (in real time) with tail -f ???? specificUser
-2
votes
1answer
60 views

tail -n 10 is truncating my entire file [duplicate]

I have these 2 scripts, one is writing to the file: #!/usr/bin/env bash while true; do sleep 1; echo "$(uuidgen)" >> /tmp/cprev.stdout.log done; the other is reading the last 10 lines ...
0
votes
0answers
25 views

Log recording with tail -f

Is there any function in linux's tail utility that lets use save a recording. The scenario is: At current line in log, start recording Do operation that can generate logs, or many logs Stop and save ...
0
votes
1answer
27 views

How to tail on demand based on a search and colorized the result

Hi I have a log file that has a lot of information and it is pretty difficult to spot what I am looking for, so I came to this command that show me only what I want to see in the log, it will act as a ...
47
votes
3answers
20k views

Does “less” have a feature like “tail --follow=name” (“-F”)

The command less can be used to replace tail in tail -f file to provide features like handling binary output and navigating the scrollback: less +F file The + prefix means "pretend I type that ...
3
votes
6answers
590 views

Move specific line from a position to another

I'm using the ubuntu terminal, I need to move a specific line in a file ( 11th position ) to the first line and then transfer the final result into a new file. The original file contains hundreds of ...
23
votes
6answers
32k 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 ...
52
votes
5answers
67k views

Output file contents while they change

I want to output a file's contents while they change, for example if I have the file foobar and I do: magic_command foobar The current terminal should display the file's contents and wait until, I ...
29
votes
7answers
43k views

How do you keep only the last n lines of a log file?

A script I wrote does something and, at the end, appends some lines to its own logfile. I'd like to keep only the last n lines (say, 1000 lines) of the logfile. This can be done at the end of the ...
2
votes
4answers
3k 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
2answers
156 views

How to get country code/name in the tail command result?

I have asked this question about filtering out a LOG file The LOG file is : Jan 26 01:05:47 server54 kernel: [41s58.6w4335] INPUT:DROP: IN=eth4 OUT= MAC=d3:ss:43:23:23:43 SRC=1.1.1.1 DST=127.0.0.0 ...
1
vote
1answer
50 views

How can I use “tail -f” to follow a file but without displaying any lines until additional lines are added?

I'd like to output just the lines that are added to a file after the "tail" command is run. i.e. not output any lines that existed in the file before the "tail" command is executed. So far, a "tail -f"...
0
votes
0answers
38 views

Execute an action if a log file contains a text

i have a question about executing a command if a certain text is in a log file. There is already the article: https://unix.stackexchange.com/questions/12075/best-way-to-follow-a-log-and-execute-a-...
4
votes
9answers
706 views

Is it possible to truncate a file (in place, same inode) at the beginning?

It is possible to remove trailing bytes of a file without writting to a new file (> newfile) and moving it back (mv newfile file). That is done with truncate: truncate -s -1 file It is possible ...
57
votes
6answers
81k 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 ...
0
votes
0answers
45 views

How to tail running log and grep or awk multiple strings in sequence then terminate

I am facing an issue to use shell script restart server and confirm it restart success immediately after observing multiple strings in sequence, the case is i have to monitor a running log, as example ...
1
vote
0answers
14 views

want to live monitor all log files in one vieuw

I like to view all log files live like tail -n0 somelog.log But then for literally all log files on the system (CentOS 7) Or an other way to do this is also nice. I want to output this to a web page ...
1
vote
1answer
164 views

How to process a logfile from tail -f into awk into jq?

My Use-Case is as following: I have a Apache Logfile where I am logging only json-data from PHP. Because of how Apache is printing the Logs I have to trim the start and the end of each line with awk. ...
0
votes
1answer
27 views

stop/restart background job started by cron

I have the following cronjob which pipes docker (apache) logs into a file: * * * * * flock -n /srv/www/htdocs/scripts/pipe.lock /srv/www/htdocs/scripts/pipe_docker_logs.sh the pipe_docker_logs.sh ...
0
votes
1answer
185 views

Extract last lines of a logfile by time

tail -n 100 myfile.log gives my the last 100 lines of myfile.log. Is there an existing tool that expects the first "column" of each line in a file as a timestamp and can give me the n last hours/...
0
votes
2answers
984 views

Show particular lines using only head and tail

I want to show the 3th and the 7th lines in a file only using commands head and tail (I don't want to show the lines between the 3th and the 7th).
10
votes
5answers
40k views

Using head and tail to grab different sets of lines and saving into same file

So this is for homework, but I will not be asking the specific homework question. I need to use head and tail to grab different sets of line from one file. So like lines 6-11 and lines 19-24 and ...
58
votes
5answers
26k views

monitor files (à la tail -f) in an entire directory (even new ones)

I normally watch many logs in a directory doing tail -f directory/*. The problem is that a new log is created after that, it will not show in the screen (because * was expanded already). Is there a ...
1
vote
0answers
50 views

Grep something that is between two known strings

I have a large potentially zipped log file and I can identify which line number some text I'm interested in is on using: find . -name "*" -exec zgrep -C 1 -n -i -H TextToFind {} \; But in a second ...
2
votes
2answers
806 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
2answers
91 views

monitor log files and take actions upon a certain entry

i want to do the following: tail -f some file { if newline matches/contains somestring ( perform action1; perform action2; ...; more actions) somestring2 ( ...
1
vote
1answer
41 views

How to send new lines from file to a tcp port?

Wait for file changes and send new lines to a TCP port server. I've tried nc 127.0.0.1 1234 -c "tail -F /var/log/changes.log" & But get broken pipe
-1
votes
3answers
43 views

Get last “block” (pattern) of log file

my logfile: ... ---------- text1 text2 ---------- text3 text4 ---------- And now I want to grep only the last block (between "----------") -> text3/text4 Thank you :-) Didn't find any solution... ...
57
votes
10answers
43k 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 ...
0
votes
1answer
106 views

Find command, -exec tail and file browser

I want to use the find command and open the file browser (Nemo) with the results: This does it find . -name "foo*" -exec nemo {} + It opens a new window for each result. So to avoid opening tons of ...

1
2 3 4 5
7