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

learn more… | top users | synonyms

13
votes
2answers
7k views

Tail log file on multiple machines over ssh

I'm trying to tail a log file on multiple remote machines and forward the output to my local workstation. I want connections to close when pressing Ctrl-C. At the moment I have the following function ...
19
votes
2answers
1k 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
32 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 ...
4
votes
5answers
1k views

Only output most recent 10 (or n) lines of a lengthy command output

I have a command that outputs thousands of lines. I actually need these lines in order to see the progress of the command. But I do not need to see more than the 10 most recent lines. How can I do ...
153
votes
18answers
85k 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 ...
0
votes
2answers
38 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
41 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 ...
1
vote
2answers
62 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 '/...
0
votes
1answer
44 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
48 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 ...
13
votes
2answers
2k views

“tail -f | iconv -fsjis” does not output anything

I want to tail -f a file, but its content is in sjis encoding, so I need to have it converted to the native (utf-8) encoding of my terminal. When I do tail -f x | iconv -fsjis there will be no ...
20
votes
9answers
41k 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. ...
18
votes
4answers
1k 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 ...
58
votes
6answers
101k 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
3answers
321 views

Help with 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 ...
0
votes
0answers
18 views

Possibility to write some words in different color in log file [duplicate]

Is there a possibility to colorize words in a log file? I want to have the word ERROR in my logfile always in red, to see it more easily. I watch it with the tail function: tail -f -n 500 catalina....
0
votes
1answer
16 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 ------------------------- ---------------- ------------...
0
votes
1answer
37 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
51 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 ...
2
votes
1answer
52 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
69 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
58 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 ...
16
votes
4answers
3k views

How to do a continous 'wc -l' with gnu texttools?

I know of course that cat logfile.txt | wc -l 120 will tell me the number of lines in a file. Whereas tail -f logfile.txt will show me the new lines that another program writes to logfile.txt. ...
1
vote
2answers
503 views

tail -f equivalent

I am seeing a delay of several seconds with the tail command. I found the cause for it has something to do with nfs services. I am using Arch linux and yet to find out how to disable all these ...
6
votes
4answers
4k views

is there 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 ...
18
votes
4answers
20k views

Grep from the end of a file to the beginning

I have a file with about 30.000.000 lines (Radius Accounting) and I need to find the last match of a given pattern. The command: tac accounting.log | grep $pattern gives what I need, but it's too ...
0
votes
0answers
18 views

Script acting as textfile, possible? [duplicate]

A program I'm running has a -logFile option. The file I set as a logfile is filling up quite rapidly, and I only need about half of what's actually in it. Is it at all possible to: have a script (...
0
votes
1answer
33 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. ...
3
votes
2answers
155 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
64 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 ...
2
votes
4answers
663 views

How to change color of a character while tailing and tr

I regularly use this command line but I would like to change the color of the "|" to green in the output. Does anyone know how I can accomplish this? tail -f file.log | tr '\001' '|' | grep TEST
0
votes
4answers
68 views

How to use tail for multiple files [closed]

I have multiple files. I need to use tail to remove some lines. How can I get the files after using the tail command? I am having problems redirecting the files.
5
votes
2answers
289 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 ...
2
votes
2answers
103 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
42 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 ...
-5
votes
1answer
2k 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
35 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
5answers
75 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 ...
15
votes
5answers
7k 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". ...
1
vote
1answer
79 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:...
4
votes
1answer
72 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
93 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 ...
1
vote
2answers
640 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 ...
8
votes
1answer
3k views

Convert newlines to null-delimited when using tail

How can I change the output from tail to use null-terminated lines instead of newlines? My question is similar to this one: How to do `head` and `tail` on null-delimited input in bash?, but differs ...
4
votes
2answers
36 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 ...
20
votes
6answers
20k 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 ...
4
votes
4answers
626 views

Prevent tail from modifying the charset of the terminal

In a Linux terminal (CentOS) I am using the command tail --follow=name my-rolling-file.log in order to see the logs of my application. Sometimes in the log there is some binary data dumped (I dump ...
3
votes
1answer
346 views

POSIX head and tail not feature equivalent

The documentation for POSIX tail's -n option says that The origin for counting shall be 1; that is, -n +1 represents the first line of the file, -n -1 the last. So tail -n 10 (used later on the ...
0
votes
2answers
70 views

Monitor a logfile and execute different commands depending on different conditions

I have a logfile which I want to monitor and depending on which condition is met, different commands should be executed. I found a solution that comes close to this here. Unfortunately it doesn't ...
4
votes
2answers
2k views

How to tail a log file by time?

Say my log file(log.txt) is something like 2014-01-01 22:30:30 something happened.... 2014-01-01 22:30:31 something happened.... 2014-01-01 22:30:41 something happened.... I want to tail this file ...