Questions tagged [tail]

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

Filter by
Sorted by
Tagged with
-1
votes
2answers
118 views

Tail a file on Mainframe that needs conversion [closed]

I want to tail a log file in Unix system services on a Mainframe LPAR that needs a ASCII to EBCDIC conversion?
2
votes
2answers
124 views

tailf output as script parameter

Why is it when I leave the following tailf running: tailf /var/log/z-way-server.log | grep --line-buffered device-info | gawk 'BEGIN { FS = "\"" } ; {print $4,"is",$8}' I get my desired output: Den ...
0
votes
1answer
95 views

Combined linux commands not writing outfile.txt

I want to search in a log file (real-time) for the contents of msg="yxyxyx" and then write the unique values to outfile.txt I wrote this: tail -f /var/log/firewall.log | sed -n '/msg=/{s/.*msg=//;s/\...
16
votes
1answer
927 views

How to get an average pipe flow speed

If myfile is increasing over time, I can get the number of line per second using tail -f | pv -lr > /dev/null It gives instantaneous speed, not average. How can I get the average speed (i.e the ...
6
votes
1answer
424 views

Get complete last row of `df` output

I would like to execute the command df -h /etc/nginx/access_log_backup_directory/ | tail -1 Depending on the file system lenth the command df -h /etc/nginx/access_log_backup_directory/ gives the ...
4
votes
2answers
1k 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: ...
-1
votes
1answer
1k views

how to find the output for a file if head number and tail number is given

If file foo contains 9 lines, each of which is the one-digit line number of the line in the file (1 through 9), what is the output on your screen of this command: sort foo foo | tail -2 | head -1 ...
49
votes
4answers
62k 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 ...
30
votes
7answers
45k 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 ...
4
votes
1answer
4k views

“tail -f” using “tcpdump -r”

To display content of pcap file , we use : tcpdump -r /Path/to/syscontection.pcap; However, this command line does not follow the pcap file on realtime , like tail -f which follows a plain text . ...
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 '.*...
4
votes
4answers
3k views

tail -f a file for 10 minutes / until N matching lines?

I've got a log file that I process as follows: grep pattern /var/log/whatever.log | \ cut ... | sort | uniq -c | sort -rn | \ etc.... However, the log file is quite big, and records events ...
3
votes
1answer
189 views

How can I display the first few line of a file with updates?

When watching the last few lines of a text files for changes, I can use tail -f to continue updating my display. How can I achieve the same thing with head? Is there some solution which behaves like ...
0
votes
3answers
1k views

echo lines of file - but no more than N characters per line [duplicate]

I would like to print the tail of a file (could be also head or cat in general) to the screen but restrict the number of characters per line. So if a file contains ... abcdefg abcd abcde abcdefgh .....
0
votes
1answer
295 views

any way to combine grep and tail to monitor table creation from command line

I have a process which is dumping data to a file. It is a list of transactions and typically is about 3.8G in size. to do a tail -f file.txt is not very useful, however, each batch of transactions ...
25
votes
6answers
15k views

How keep last 50 lines in logfile

I try to keep last 50 lines in my file where I save temperature every minute. I used this command: tail -n 50 /home/pi/Documents/test > /home/pi/Documents/test But the result is empty test file. ...
1
vote
1answer
413 views

How to actively grep log for the last 15 seconds for a phrase?

I have this bash script and inside the script, I am trying to grep a log for the words "status change" and then after I find the most recent line that contains the words "status change" (aka the most ...
1
vote
1answer
799 views

Assign continuous stream to variable and process the variable

I'm trying to make an analyzer for a custom log that I have. My log file has a duration timestamp (in ms) which I want to filter out from the others and send me the logs that take over a threshold ...
4
votes
5answers
2k views

Tail a file for specific text

Is there a Linux command similar to tail where instead of specifying a number of lines you can specify a string of text, the file would be searched for that text from the last line to the first and ...
1
vote
1answer
143 views

Watch/View file contents but no new lines added

This post 'Output file contents while they change' is similar but the answer doesn't work for my case. Tail -f doesn't seem to refresh the output when the file's size doesn't change or when there are ...
0
votes
1answer
183 views

Colorized tail: How to set default color

I have a function setup to provide color to the tail command using ANSI escape sequences with sed. function colortail { tail -f -n30 $1 | sed -e 's/\(.*MINOR.*\)/\o033[93m\1\o033[39m/' -e 's/.*MAJOR....
46
votes
2answers
35k views

What is the difference between “tail -f” and “tail -F”?

I never used tail -F command instead always used tail -f however someone told me that -F is better without much explanation. I looked up man page for tail command. -f output appended data as the ...
1
vote
2answers
3k views

How to stop “tail -f” within a running script? [duplicate]

How can you stop a tail -f command after seeing a specific string/word? I'm trying to follow an expanding log and stop the tail after finding a specific word. Is there any kill command for that? I'm ...
1
vote
2answers
32k views

How to extract first and last lines in a file? [duplicate]

File1 Sergio Lionel Luis Andreas Gerard I want my stdout to have just Sergio Gerard How can I do this using the tail command and piping?
1
vote
4answers
133 views

How to extract first name in Alphabetical order from multiple files

Say I have File1: Aaron Vernon Troy Roy File2: Jason Derek Mariano Alex I want to display: File1: Aaron File2: Alex What would be a single line bash command that could do both? I was ...
2
votes
2answers
1k views

How can I use Awk to convert a unix timestamp to human readable when doing a Tail -f logfile?

I'm currently doing a tail -f mysql.log and also have it color coded. But how would I use awk to convert the unix timestamps to human readable format? tail -f /var/lib/mysql/mysql-slow.log | awk '/...
1
vote
1answer
1k views

How to Tail -f output with colors using only Awk and show the rest of the output?

I was able to do a tail -f output with colors using the awk command. But I'm unsure how to output the rest of the log as it seems to be filtering only those 2 lines. I also want to see the other lines ...
1
vote
1answer
1k views

Filter out duplicate lines of tail -f [duplicate]

I often need to tail -f apache access logs for websites to troubleshoot issues- one thing that makes it annoying is that anyone loading a page once may cause 12+ lines to get written to the log, and ...
23
votes
4answers
9k views

How can I see the whole file and also wait for more data to be added to that file?

I want to read whole file and make it waiting for input, just like tail -f but with the complete file displayed. The length of this file will always change, because this is a .log file. How can I ...
0
votes
1answer
283 views

monitor simple process output

On my system I can check a job's status using qstat: $ qstat 2048930 Job ID Name User Time Use S Queue ------------------------- ---------------- ------------...
1
vote
1answer
370 views

Cygwin - tail stops reading input pipe after first write

I have the following script to run my application in Ubuntu with redirecting its input (where $in is named pipe which is used to send text lines to stdin). tail -f "$in" | "$app_bin" $app_args & ...
0
votes
1answer
514 views

Showing color in log output using tail command when using Cygwin?

I have a debian install that runs an application server. I ssh into this debian install from a Windows computer using cygwin and with the application server running I use tail -f to monitor the log ...
5
votes
1answer
577 views

How to convert a timezone in logs as they are being tailed

I would like to manipulate the format of a datestamp from a log, in realtime, as it is being tailed. The current format is 2016-04-06T23:19:20.878Z. I would like to convert it to our local timezone ...
0
votes
1answer
966 views

removing duplicates with tail [closed]

How can I remove duplicate in tail output? I'm using tail -f file.txt | sort file.txt | uniq it stops tail after some sec
2
votes
4answers
446 views

Not enough disk space: remove first n lines of text file without copying the file [duplicate]

I want to remove the first $rmv lines of a huge text file called $filename. This text file is so big that I cannot fit two copies of it on my hard drive. The following leaves me with a blank file ...
0
votes
3answers
6k 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 ...
6
votes
2answers
4k views

Trace a binary stream from a device file

I'm debugging a binary stream that is coming from a device file. I would like to have the output printed out in real time as hex values. So far I've used tail -f /dev/ttyAPP2 | hexdump -C but after ...
0
votes
1answer
532 views

Possible to prevent multitail from closing “finished” command windows?

Assume a multitail call like the following: multitail -s 2 -l "long-running-command" -l "short-running-command" Now, I would like to have both windows remain open, even after they are finished. ...
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 ...
11
votes
2answers
17k views

Command to remove the first N number of lines in input

Background I am running an SSH server and have this user that I want to delete. I cannot delete this user because he is currently running a few processes that I need to kill first. This is the ...
3
votes
2answers
1k views

“cut” hangs when using “tail -f” in combination with “tr”

I'm try to pipe chat log files to some speech output, and want to remove timestamps with cut and remove special characters with tr. Unfortunately, cut seems to halt when using it with tail -f in ...
0
votes
1answer
242 views

Head and Tail of a directory, set by the user

I have this script that will show the user the head or tail of the files that are inside a set directory (currently that is set as '~/bin/new/*'). This script works but i would like to allow the user ...
-7
votes
1answer
6k views

Head and tail command

How can i do this exercise in unix? Create the following command: lshead.bash – list the first few lines of every file in a directory specified by the argument. This command should also allow options ...
1
vote
1answer
349 views

Replicating growing log files in a near real-time manner over the network

I have a server with a bunch of processes writing log files as they run. I need to enable a client host to get a replica of the server-side log files in a near real-time manner. Is there a better way ...
1
vote
1answer
687 views

tail: illegal option — -53\r error while using head and tail on same file in single script

I am using a=`head -1 Rt.in` to get first value from my file and I am saving it as a variable then I am using same variable to tail -$a to tail last lines from my input. But it is giving an error: ...
3
votes
5answers
875 views

exit tail when other process is done

I have parallel --j 2 -- "sh script1" "sh script2" where script1 and script2 log in files log1 and log2 I would like to change this to: parallel --j 3 -- "sh script1" "sh script2" "tail -f log1 ...
9
votes
1answer
200 views

Is this tail behavior in Grouping Commands specified by POSIX?

Using tail combined with other standard tools in Grouping Commands can make some powerful constructions. For example, to get the first and last line of a file: $ seq 10 > file $ { head -n1; tail -...
0
votes
1answer
984 views

How to tail -f against a file which is rolled every 500MB / daily?

I would like to do the following to monitor for a pattern in a log file: tail -f ./app.log | grep "My Pattern: .*" >> ./MyPattern.txt & This is working fine until the app.log reaches 500MB ...
1
vote
2answers
7k views

How can I print the second to last line of many files into one file? [duplicate]

I have many CSV files in one directory which have various lengths. I'd like to put the second to last line of each file into one file. I tried something like tail -2 * | head -1 > file.txt, then ...
4
votes
2answers
239 views

Interactive, tabbed live tail of multiple files?

I'm often tailing multiple files, and even with a terminal multiplexer (ie tmux or screen) it's still annoying to have multiple windows/shell sessions dedicated to watching multiple files. Is there ...

1 2 3
4
5
7