📄 alias.sh
字号:
#!/bin/bash# alias.shshopt -s expand_aliases# Must set this option, else script will not expand aliases.# First, some fun.alias Jesse_James='echo "\"Alias Jesse James\" was a 1959 comedy starring Bob Hope."'Jesse_Jamesecho; echo; echo;alias ll="ls -l"# May use either single (') or double (") quotes to define an alias.echo "Trying aliased \"ll\":"ll /usr/X11R6/bin/mk* #* Alias works.echodirectory=/usr/X11R6/bin/prefix=mk* # See if wild card causes problems.echo "Variables \"directory\" + \"prefix\" = $directory$prefix"echoalias lll="ls -l $directory$prefix"echo "Trying aliased \"lll\":"lll # Long listing of all files in /usr/X11R6/bin stating with mk.# An alias can handle concatenated variables -- including wild card -- o.k.TRUE=1echoif [ TRUE ]then alias rr="ls -l" echo "Trying aliased \"rr\" within if/then statement:" rr /usr/X11R6/bin/mk* #* Error message results! # Aliases not expanded within compound statements. echo "However, previously expanded alias still recognized:" ll /usr/X11R6/bin/mk*fi echocount=0while [ $count -lt 3 ]do alias rrr="ls -l" echo "Trying aliased \"rrr\" within \"while\" loop:" rrr /usr/X11R6/bin/mk* #* Alias will not expand here either. # alias.sh: line 57: rrr: command not found let count+=1done echo; echoalias xyz='cat $0' # Script lists itself. # Note strong quotes.xyz# This seems to work,#+ although the Bash documentation suggests that it shouldn't.## However, as Steve Jacobson points out,#+ the "$0" parameter expands immediately upon declaration of the alias.exit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -