24.07.2018 Views

Bash-Beginners-Guide

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

alias e='vi'<br />

alias egrep='grep -E'<br />

alias ewformat='fdformat -n /dev/fd0u1743; ewfsck'<br />

alias fgrep='grep -F'<br />

alias ftp='ncftp -d15'<br />

alias h='history 10'<br />

alias fformat='fdformat /dev/fd0H1440'<br />

alias j='jobs -l'<br />

alias ksane='setterm -reset'<br />

alias ls='ls -F --color=auto'<br />

alias m='less'<br />

alias md='mkdir'<br />

alias od='od -Ax -ta -txC'<br />

alias p='pstree -p'<br />

alias ping='ping -vc1'<br />

alias sb='ssh blubber'<br />

alias sl='ls'<br />

alias ss='ssh octarine'<br />

alias tar='gtar'<br />

alias tmp='cd /tmp'<br />

alias unaliasall='unalias -a'<br />

alias vi='eval `resize`;vi'<br />

alias vt100='export TERM=vt100'<br />

alias which='type'<br />

alias xt='xterm -bg black -fg white &'<br />

franky ~><br />

Aliases are useful for specifying the default version of a command that exists in several versions on your<br />

system, or to specify default options to a command. Another use for aliases is for correcting incorrect spelling.<br />

The first word of each simple command, if unquoted, is checked to see if it has an alias. If so, that word is<br />

replaced by the text of the alias. The alias name and the replacement text may contain any valid shell input,<br />

including shell metacharacters, with the exception that the alias name may not contain "=". The first word of<br />

the replacement text is tested for aliases, but a word that is identical to an alias being expanded is not<br />

expanded a second time. This means that one may alias ls to ls -F, for instance, and <strong>Bash</strong> will not try to<br />

recursively expand the replacement text. If the last character of the alias value is a space or tab character, then<br />

the next command word following the alias is also checked for alias expansion.<br />

Aliases are not expanded when the shell is not interactive, unless the expand_aliases option is set using<br />

the shopt shell built-in.<br />

3.5.2. Creating and removing aliases<br />

<strong>Bash</strong> <strong>Guide</strong> for <strong>Beginners</strong><br />

Aliases are created using the alias shell built-in. For permanent use, enter the alias in one of your shell<br />

initialization files; if you just enter the alias on the command line, it is only recognized within the current<br />

shell.<br />

franky ~> alias dh='df -h'<br />

franky ~> dh<br />

Filesystem<br />

Size Used Avail Use% Mounted on<br />

/dev/hda7 1.3G 272M 1018M 22% /<br />

/dev/hda1 121M 9.4M 105M 9% /boot<br />

/dev/hda2<br />

13G 8.7G 3.7G 70% /home<br />

/dev/hda3<br />

13G 5.3G 7.1G 43% /opt<br />

none 243M 0 243M 0% /dev/shm<br />

/dev/hda6<br />

3.9G 3.2G 572M 85% /usr<br />

Chapter 3. The <strong>Bash</strong> environment 52

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!