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
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 ...
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 ...
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
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
56 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 ...
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
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 ...
3
votes
6answers
586 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
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-...
0
votes
0answers
44 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
702 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
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
161 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
26 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
184 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
979 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
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 ...
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... ...
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 ( ...
0
votes
1answer
103 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
837 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
125 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
66 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
55 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
81 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 ...
5
votes
2answers
188 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
197 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
25 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
67 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
799 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
2k 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
295 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
180 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
54 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
2k 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
198 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
1k 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
2 3 4 5
7