2014年3月19日星期三

Linux Commands for Beginners lesson 12 -- Create Your Own Commands Via alias

In this part, I will show you how to create your own commands via alias




1.COMMAND:
    alias
  DESCRIPTION:
    The alias command can be useful if you want to create a 'shortcut' to a command.
  SYNOPSIS:
    alias name='command'


 TIPS:
    To see a list of aliases set up on your linux, just type alias at the prompt.

Example:
piniheaven@fish:~/Documents$alias    #list aliases set up on your system
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'

alias ls='ls --color=auto'

piniheaven@fish:~/Documents$ aliasMyLs='ls -l'   #create an alias of 'ls -l'
piniheaven@fish:~/Documents$ ls
assemble  C++primer_ex  C++primer_note  Ebook  linux  MyScript  QT_ex  QT_note  tutorial
piniheaven@fish:~/Documents$ MyLs
total 36
drwxrwxr-x  4 piniheaven piniheaven 4096 Aug 22 12:16 assemble
drwxrwxr-x  2 piniheaven piniheaven 4096 Jul 19 14:12 C++primer_ex

......
......
drwxrwxr-x  2 piniheaven piniheaven 4096 Jul 19 00:21 QT_note
dr-xr-xr-x  2 jack       piniheaven 4096 Aug 25 21:42 tutorial



2.COMMAND:
    unalias
  DESCRIPTION:
    unalias command is used to remove an alias (see alias).
  SYNOPSIS:
    unalias commandName


Example:
piniheaven@fish:~/Documents$ unalias MyLs     #unalias Myls command
piniheaven@fish:~/Documents$ MyLs
MyLs: command not found

没有评论:

发表评论