Little Helpers

[ Scripts ] [ Aliases ]

Scripts

tarball

A shell script frontend for the most common uses of tar: creating, unpacking and listing contents of tar archives.

Download. Documentation: HTML / manpage (gzipped)

Aliases

Show IP

When using a dial-up connection, internet providers usually assign a different IP from their pool to the machine dialling in. To quickly get at the current IP one can use ifconfig and extract the IP from the command's output by using pattern matching.

Example for PPP connections (ifconfig 1.40):
alias myip='expr "`/sbin/ifconfig`" : ".* inet addr:\([^ ]*\) P-t-P:.*"'

Where (bash)

To locate the command that will be executed when its name is typed in the shell, one can use which(1) (bash: type -p can be used as a substitute): which commandname looks for the program called commandname along the search path and displays the first hit (if any). However, aliases and shell functions are not taken into account (tcsh has a builtin which that does this). Also, only the first hit along the search path is shown, even if there are several instances in different directories of the search path (such as, for example, in /usr/bin as well as /usr/local/bin). The command where serves to show all these (again, tcsh has a builtin version).

where for bash:
alias where='type -a'
Example:
$> /usr/bin/which ls # which(1)
/bin/ls
$> type -p ls # bash builtin "which"
$> where ls # alias for "type -a ls"
ls is aliased to `ls $LS_OPTIONS'
ls is /bin/ls

Michael Peceny
Aug 30, 2001