Check These Out
Thanks to knoppix5 for the idea :-)
Print selected lines from a file or the output of a command.
Usage:
$ every NTH MAX [FILE]
Print every NTH line (from the first MAX lines) of FILE.
If FILE is omitted, stdin is used.
The command simply passes the input to a sed script:
$ sed -n -e "${2}q" -e "0~${1}p" ${3:-/dev/stdin}
print no output
$ sed -n
quit after this many lines (controlled by the second parameter)
$ -e "${2}q"
print every NTH line (controlled by the first parameter)
$ -e "0~${1}p"
take input from $3 (if it exists) otherwise use /dev/stdin
${3:-/dev/stdin}
Shorter version using --tag
Here the !!:1 will take the first parameter from the previous command. This can be used in conjunction with other history commands like ! and so on.
Very useful in shell scripts because you can run a task nicely in the background using job-control and output progress until it completes.
Here's an example of how I use it in backup scripts to run gpg in the background to encrypt an archive file (which I create in this same way). $! is the process ID of the last run command, which is saved here as the variable PI, then sleeper is called with the process id of the gpg task (PI), and sleeper is also specified to output : instead of the default . every 3 seconds instead of the default 1. So a shorter version would be sleeper $!;
The wait is also used here, though it may not be needed on your system.
$ echo ">>> ENCRYPTING SQL BACKUP"
$ gpg --output archive.tgz.asc --encrypt archive.tgz 1>/dev/null &
$ PI=$!; sleeper $PI ":" 3; wait $PI && rm archive.tgz &>/dev/null
Previously to get around the $! not always being available, I would instead check for the existance of the process ID by checking if the directory /proc/$PID existed, but not everyone uses proc anymore. That version is currently the one at http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html but I plan on upgrading to this new version soon.
As of March 7, 2012:
$ brew update - downloads upgraded formulas
$ brew upgrade [FORMULA...] - upgrades the specified formulas
$ brew outdated - lists outdated installations
Note updating all packages may take an excruciatingly long time. You might consider a discriminating approach: run `brew outdated` and select specific packages needing an upgrade.
For more information see homebrew's git repository: https://github.com/mxcl/homebrew
The original doesn't work for me - but this does. I'm guessing that Youtube updated the video page so the original doesn't work.