tail -f *[!.1][!.gz]

useful tail on /var/log to avoid old logs or/and gzipped files

with discard wilcards in bash you can "tail" newer logs files to see what happen, any error, info, warn...
Sample Output
root@llistes:/var/log/mailman# tail -f *[!.1][!.gz]
==> error <==

==> post <==

==> qrunner <==
Mar 06 06:31:51 2009 (30465) OutgoingRunner qrunner caught SIGHUP.  Reopening logs.
Mar 06 06:31:51 2009 (30464) NewsRunner qrunner caught SIGHUP.  Reopening logs.
Mar 06 06:31:51 2009 (30467) RetryRunner qrunner caught SIGHUP.  Reopening logs.
Mar 06 06:31:51 2009 (30466) VirginRunner qrunner caught SIGHUP.  Reopening logs.
Mar 06 06:31:51 2009 (30461) BounceRunner qrunner caught SIGHUP.  Reopening logs.
Mar 06 06:31:51 2009 (30463) IncomingRunner qrunner caught SIGHUP.  Reopening logs.
Mar 06 06:31:51 2009 (30462) CommandRunner qrunner caught SIGHUP.  Reopening logs.
Mar 06 06:31:51 2009 (30460) ArchRunner qrunner caught SIGHUP.  Reopening logs.
Mar 06 06:31:51 2009 (30455) Master watcher caught SIGHUP.  Re-opening log files.

==> smtp <==

==> subscribe <==
Mar 05 13:49:58 2009 (32332) test: new dreg@dreg.com, 
Mar 05 13:49:58 2009 (32332) test: new nice@renice.co.uk, 
Mar 05 13:49:58 2009 (32332) test: new thisisanemail@somailed.it, 

==> vette <==

5
By: piscue
2009-03-06 16:24:44

These Might Interest You

  • This command finds the 5 (-n5) most frequently updated logs in /var/log, and then does a multifile tail follow of those log files. Alternately, you can do this to follow a specific list of log files: sudo tail -n0 -f /var/log/{messages,secure,cron,cups/error_log} Show Sample Output


    5
    ls -drt /var/log/* | tail -n5 | xargs sudo tail -n0 -f
    kanaka · 2009-07-22 14:44:41 0
  • If you use 'tail -f foo.txt' and it becomes temporarily moved/deleted (ie: log rolls over) then tail will not pick up on the new foo.txt and simply waits with no output. 'tail -F' allows you to follow the file by it's name, rather than a descriptor. If foo.txt disappears, tail will wait until the filename appears again and then continues tailing.


    15
    tail -F file
    recursiverse · 2009-07-23 07:37:11 1
  • This decompresses the file and sends the output to STDOUT so it can be grepped. A good one to put in loops for searching directories of gzipped files, such as man pages. Show Sample Output


    -7
    zcat /usr/share/man/man1/grep.1.gz | grep "color"
    root · 2009-02-04 09:38:45 2
  • Tail all logs that are opened by all java processes. This is helpful when you are on a new environment and you do not know where the logs are located. Instead of java you can put any process name. This command does work only for Linux. The list of all log files opened by java process: sudo ls -l $(eval echo "/proc/{$(echo $(pgrep java)|sed 's/ /,/')}/fd/")|grep log|sed 's/[^/]* //g'


    -1
    sudo ls -l $(eval echo "/proc/{$(echo $(pgrep java)|sed 's/ /,/')}/fd/")|grep log|sed 's/[^/]* //g'|xargs -r tail -f
    vutcovici · 2010-07-30 18:20:00 0

  • 0
    ssh user@remote "tar cfp - /path/to/log/* | gzip" > local.tar.gz
    vaaclav · 2013-04-30 09:18:18 0
  • Works in Ubuntu, I hope it will work on all Linux machines. For Unixes, tail should be capable of handling more than one file with '-f' option. This command line simply take log files which are text files, and not ending with a number, and it will continuously monitor those files. Putting one alias in .profile will be more useful.


    6
    find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f
    mohan43u · 2009-06-03 09:47:08 7

What Others Think

Really nice !
CodSpirit · 480 weeks and 6 days ago
I was wondering if somebody could explain to me what exactly the function of the square brackets is.
kzh · 461 weeks and 2 days ago
From the bash manpage, under "Pattern Matching", "[...] Matches any one of the enclosed characters." "If the first character following the [ is a ! or a ^ then any character not enclosed is matched." RTFM.
realist · 457 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: