Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*"
Favorites infavorites:mine
Status closed:yes
Types is:question
Exclude -[tag]
For more details on advanced search visit our help page
Results tagged with Search options answers only user 22565

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

What about: tail -f file1 & tail -f file2 Or: tail -f file1 | sed 's/^/file1: /' & tail -f file2 | sed 's/^/file2: /' To follow all the files whose name match a pattern, you could implement the … tail -f (which reads from the file every second continuously) with a zsh script like: #! /bin/zsh - zmodload zsh/stat zmodload zsh/zselect zmodload zsh/system set -o extendedglob typeset -A tracked …
answered Aug 7 '14 by Stéphane Chazelas
tail will die of a SIGPIPE signal as soon as it tries to write to the pipe when it has no reader. So tail will die soon after head has finished outputting its 10000 lines and exited. Because pipes … can hold some data (64kiB on Linux) and because tail buffers its output when not to a terminal (8kiB in my test) and head and tail read their input in chunks (of up to 8kiB in my tests), tail may read …
answered Feb 28 '14 by Stéphane Chazelas
Since the old style options like -5, +5 are only recognised as the first argument, you could do: head() case $1 in ([-+][0-9]*) command head "$@";; (*) command head -n 15 "$@" esac That …
answered Mar 3 '14 by Stéphane Chazelas
(which uses tj()) not Korn syntax (which uses function tj without ()). Some shells (bash, zsh, pdksh) do support it mostly by accident. tail -100f is unspecified by POSIX. The POSIX syntax is tail -f -n … 100 POSIX tail takes at most one argument, the behaviour is unspecified if you pass more than one argument. Some implementations like GNU tail are able to watch more than one file in parallel, but …
answered Feb 9 '18 by Stéphane Chazelas
tail will only output the last 10 lines. So one way or another, you'll have to tell it you've finished typing so it knows what lines (the 10 last ones) to output. If you press CTRL-C (the default … most systems) on an empty line. Then tail will detect that the end of input is being reached and will output the 10 last lines that it has received. …
answered Feb 25 '13 by Stéphane Chazelas
It's not tail, it's the piping. mysql uses a tabular with ASCII boxing output format when its stdout is a terminal device, when it's intended for a user, and reverts to a scripting format when it's … ... | tail -n +2 But if the point is to remove the header line, just use -N, with or without -t. Here to get the values from the database as raw as possible and without header, I'd use: mysql …
answered Nov 23 '17 by Stéphane Chazelas
a different pipe instance). In: tail -f file Like cat, tail will wait for a process to open a file for writing. But here, since you didn't specify a -n +1 to copy from the beginning, tail will … need to wait until eof to find out what the last 10 lines were, so you won't see anything until the writing end is closed. After that, tail will not close its fd to the pipe which means the pipe …
answered Sep 17 '17 by Stéphane Chazelas
Same as @muru's but using the modulo operator instead of storing and deleting: tail -fn+1 some/file | awk -v n=30 ' NR > n {print s[NR % n]} {s[NR % n] = $0} END{for (i = NR - n + 1; i <= NR; i++) print s[i % n]}' …
answered Apr 3 by Stéphane Chazelas
While tail -n +4 to output the file starting at the 4th line (all but the first 3 lines) is standard and portable, its head counterpart (head -n -3, all but the last 3 lines) is not. Portably, you'd …
answered May 19 '15 by Stéphane Chazelas
You could always implement the tail -f (well here, unless you uncomment the seek(), more like tail -n +1 -f as we're dumping the whole file) by hand with perl for instance: perl -e ' $| = 1 … 1; $t++; } }' < your-file Or let tail -f do the tailing and use perl to insert the newlines if there's no input for 3 seconds: tail -f file | perl -pe 'BEGIN{$SIG{ALRM} = sub {print …
answered Feb 22 '18 by Stéphane Chazelas
Assuming your-filter reads its data from stdin: while your-filter; do sleep 60 done < file.log That assumes your-filter just reads the data and doesn't attempt to lseek in it for instance. Now, …
answered Aug 14 '13 by Stéphane Chazelas
Using GNU grep for the colouring: color() { GREP_COLOR=$1 grep --color '.*'; } (tail -qf /var/log/syslog | color 31 & tail -qf /var/log/fail2ban.log | color 32 & tail -qf /var/log/nginx/error.log … instead: color() { GREP_COLOR=$1 grep --line-buffered --color=always '.*'; } (tail -qf /var/log/syslog | color 31 & tail -qf /var/log/fail2ban.log | color 32 & tail -qf /var/log/nginx/error.log …
answered Aug 19 '14 by Stéphane Chazelas
Note that the problem is not with tail but with head here which reads from the pipe more than the first line it is meant to output (so there's nothing left for tail to read). And yes, it's POSIX … the whole file, while for seekable files tail would skip most of it by seeking near the end of the file. See the related discussion about buffering at Why is using a shell loop to process text …
answered Oct 29 '15 by Stéphane Chazelas
That message is output on stderr like all warning and error messages. You can either drop all the error output: tail -f file 2> /dev/null Or to filter out only the error messages that contain … truncate: { tail -f file 2>&1 >&3 3>&- | grep -v truncated >&2 3>&-;} 3>&1 That means however that you lose the exit status of tail. A few shells have a pipefail option (enabled with set -o pipefail …
answered Nov 20 '14 by Stéphane Chazelas
cmd1 == tail -f file and cmd2 == sed /w/q, tail -f will read the last 10 lines of the file and write them to stdout (the pipe), typically in one chunk unless the lines are really big and sit there … possibly with a one-line delay with some sed implementation) as it finds that line, it exits, but at that time, tail has already written to the pipe all it had to WRITE, so it won't receive a SIGPIPE …
answered Jan 10 '18 by Stéphane Chazelas

15 30 50 per page