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
Prints a string indicating whether a command is an alias, keyword, function, builtin, or file. I have used this in my BASH scripts to allow an external parameter to define which function to run, and ensure that it is a valid function that can indeed be run. Show Sample Output
Please be careful while executing the following command as you don?t want to delete the files by mistake. The best practice is to execute the same command with ls ?l to make sure you know which files will get deleted when you execute the command with rm.
print sum of disk usage for filetype within current dir and subdirs Show Sample Output
The "type" builtin command is handy to find out what executable will be used if you issue a command. But on some distros, particularly when using /etc/alternatives, certain executables get buried under layers and layers of symbolic links and it becomes hard to find which one. If you put the above command in your .bashrc, it adds a "-c" option to the type command that will weed through the symbolic links and prints the actual file that will be executed. Show Sample Output
Will find and list all core files from the current directory on. You can pass | xargs rm -i to be prompted for the removal if you'd like to double check before removal.
Prints the type of computer you have.
I think this should be used more in distros and other applications because it is so easy to get. This can also be asked by tutorials as an easy way to get your base hardware.
Some alternatives:
sudo dmidecode -s system-product-name
and
sudo smbios-sys-info-lite | sed -n 's/^Product Name: *\(.*\)/\1/p'
Show Sample Output
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: