Questions tagged [tail]

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

Filter by
Sorted by
Tagged with
-2
votes
1answer
36 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
23 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
20 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 ...
4
votes
6answers
218 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 ...
0
votes
2answers
73 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
32 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
35 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-...
0
votes
0answers
29 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 ...
4
votes
9answers
438 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 ...
1
vote
0answers
13 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
80 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
22 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
56 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
371 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).
1
vote
0answers
46 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 ...
1
vote
1answer
21 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
41 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... ...
0
votes
2answers
37 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 ( ...
0
votes
1answer
77 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 ...
2
votes
1answer
356 views

How to get tail result with line number

I tried to use tail xxxx.log | nl to get last 10 lines and their line numbers, but nl command only counts the lines of tailed result. Say there're 20 lines in that file, the returned result's actual ...
0
votes
1answer
87 views

Linux FIFO buffering depends on invocation order of readers and writers

I'm trying to write a simple python script that reads from a fifo and then writes to another fifo. I have created two FIFOs using the following command: $ mkfifo input $ mkfifo output I invoke the ...
-1
votes
1answer
63 views

How to use END {} in awk when there is no end to the input?

Say I'm using a command like tail -f ./somefile as input into my awk command. And I want to continually sum a count of matches using awk, almost like running a | wc -l at the end of a command, but ...
0
votes
1answer
49 views

Remote SSH Gnu/Linux server isn't recognizing my pipe

Basically I'm trying to run the following command: sshpass -p "xxx" ssh root@x.x.x.x "tail -f /tmp/messages | grep ptp4l" | cat -n > output.txt I'm trying to get tmp/messages to continually write ...
1
vote
0answers
63 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 ...
0
votes
1answer
85 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 ...
5
votes
2answers
134 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 ...
3
votes
3answers
140 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 ...
1
vote
1answer
24 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
53 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 ...
2
votes
2answers
480 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 ...
1
vote
1answer
1k 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
206 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 ...
1
vote
1answer
132 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
47 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?
8
votes
3answers
1k 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
0answers
29 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
159 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
894 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 ...
1
vote
1answer
82 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
149 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
38 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
67 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
1answer
926 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
601 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
47 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
1k 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
112 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
394 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
90 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
37 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-...

1
2 3 4 5
7