Uses logger in a while loop to log memory statistics frequently into the local syslog server.
5 helpful aliases for using the which utility, specifically for the GNU which (2.16 tested) that is included in coreutils.
Which is run first for a command. Same as type builtin minus verbosity
alias which='{ command alias; command declare -f; } | command which --read-functions --read-alias'
Which (a)lias
alias whicha='command alias | command which --read-alias'
Which (f)unction
alias whichf='command declare -f | command which --read-functions'
Which e(x)ecutable file in PATH
alias whichx='command which'
Which (all) alias, function, builtin, and files in PATH
alias whichall='{ command alias; command declare -f; } | command which --read-functions --read-alias -a'
# From my .bash_profile http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Show Sample Output
Output is from Debian Lenny Show Sample Output
The first argument is the interpreter for your script, the second argument is the name of the script to create. Show Sample Output
Put this one-line function somewhere in your shell init, re-login and try
whatinstalled <command>
This is an elaborate wrapper around "dpkg -S", with numerous safeguards. Symlinks and command aliases are resolved. If the searched command is not an existing executable file or was installed by some other means than dpkg/apt, nothing is printed to stdout, otherwise the package name.
Show Sample Output
Returns the pathnames of the files which would be executed in the current environment had its arguments been given as a command.
Similar to command 7822, but handles errors gracefully. Show Sample Output
This version builds on my command 8776 (Find the package a command belongs to on debian-based distros). So if you use that command to find package name then you could alternatively use following for
package summary:
function summpkg { dpkg -s $(whichpkg $1 | awk -F: '{print $1}'); }
Show Sample Output
vie myscript will find where myscript is, and then use vi to edit that file. Not much trick, but saves typing if you use it a lot.
It can be used to other nodejs packages, of course.
Saves a step between which'ing to find out the full path of a script, then copy and pasting, and less'ing the full path.
This function is used to set environmental variables from a list of alternatives depending on what's installed on the system. It returns the first program found in the list.
Example usage:
export BROWSER=$(find_alternatives chromium-browser google-chrome opera firefox firefox-bin iceweasel konqueror w3m lynx)
.
export EDITOR=$(find_alternatives vim nano pico emacs kate)
.
export PAGER=$(find_alternatives vimpager less most more pg)
alternatives: xinit $(which gnome-awesome-session) with cat /usr/local/bin/gnome-awesome-session: #!/bin/bash exec gnome-session --session awesome "$@" following: http://awesome.naquadah.org/wiki/Quickly_Setting_up_Awesome_with_Gnome note: in ubuntu 12.10 a probable Xephyr recent bug rejects keybd option ... Show Sample Output
Writes out the shebang line (#!/bin/bash) to the script.
or
which <command> > /dev/null 2>&1 || echo Error!
For example, I write
which colordiff > /dev/null 2>&1 && alias diff=colordiff
in my `~/.bashrc`.
Some people put spaces in filenames. Others have an $EDITOR environment variable set. This defaults to vim, but you can use whatever you wish: emacs, nano, ed, butterflies, etc.
This works in multiple unixes, not only linux, for different paths. On solaris, if you do not have which, you can use: ksh whence -p anypath/a_command.sh | sed "s|^./|$(pwd)|" ksh whence -p Show Sample Output
write first line `#!`
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.
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
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: