see whats getting written into all of the open logfiles under /var/log

eval `lsof +D /var/log|(read;awk '{print "tail -f " $9 " &" }'|sort|uniq)`
The result will be a bunch of 'tail' commands running in the background in your current shell.

By: p_b_r
2016-08-25 20:23:38

These Might Interest You

  • you open multiple files and you have a pattern to be replace on each one of them. For example the pattern is like this spread across hundred's of files. package1-1.12 package2-2.33 The goal is to remove the hyphen ('-') and replace with space on file{1..3} It should look like package1 1.12 package2 2.33 Here how it can be done. vim file{1..3} :bufdo :%s/-\([0-9]\)/ \1/g | w! "a1" 2L, 30C written "a2" 2L, 30C written "a3" 2L, 27C written Show Sample Output

    :bufdo :%s/<what-was>/replace-to/g | w!
    sameergawande · 2015-04-22 15:05:47 0
  • Written for Mac OSX. When you are working in a project and want to open it on, just type "gh" and your default browser will open with the repo you are in. Works for submodules, and repo's that you don't own. You'll need to copy / paste this command into a file, then create an alias in your bash or zsh profile to the script. Detailed instructions here if you still need help:

    git remote -v | grep fetch | sed 's/\(.*\)[:|/]\(.*\).git (fetch)/\2/' | awk {'print "" $1'} | xargs open
    brockangelo · 2012-04-15 20:48:46 1
  • Oracle DBA remove some logfiles which are still open by the database and he is complaining the space has not been reclaimed? Use the above command to find out what PID needs to be stopped. Or alternatively recover the file via: cp /proc/pid/fd/filehandle /new/file.txt Show Sample Output

    find -L /proc/*/fd -links 0 2>/dev/null
    res0nat0r · 2009-06-26 18:42:51 2
  • Found it on: The yet most simple way to read all the contents of a file to a variable. I used it in a perl script to replace $text="`cat /sys/...`", and stipping down 9 secs of runtime due less forks

    $text = do {local(@ARGV, $/) = $file ; <>; }; [or] sub read_file { local(@ARGV, $/) = @_ ; <>; }
    matya · 2013-06-12 11:41:49 0

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? 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.


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: