che033 unit===4   bash shell

unit===4   bash shell

-----*:matches zero or more charcters        ls  *.txt
-----?:matches any sinagle character         ls test??.txt
-----[a-z]:matches a range of characters     ls test[1-2].*
-----[^a-z]:matches all except the range     ls test[^1].*  --except 1

tab键:和cisco命令行里的一样,可以补齐命令
        也可以查找  rm 2    2009 2005
       
history:![编号]  比如:ping 192.168.1.199   ^199^1---变成ping 192.168.1.1
cd ~===========cd
cd ~user1  ===========进入user1家目录
echo $HOME==========进入主目录
/root
 
[root@mycentos ~]# echo $HOME
/root
[root@mycentos ~]# PWD
-bash: PWD: command not found
[root@mycentos ~]# pwd
/root
[root@mycentos ~]# mkdir tmp
[root@mycentos ~]# cd tmp
[root@mycentos tmp]# touch (a,b)
-bash: syntax error near unexpected token `a,b'
[root@mycentos tmp]# touch {a,b}
[root@mycentos tmp]# ls -l
total 8
-rw-r--r-- 1 root root 0 May 20 10:42 a
-rw-r--r-- 1 root root 0 May 20 10:42 b
[root@mycentos tmp]# touch a{a,b}
[root@mycentos tmp]# ls -l
total 16
-rw-r--r-- 1 root root 0 May 20 10:42 a
-rw-r--r-- 1 root root 0 May 20 10:42 aa
-rw-r--r-- 1 root root 0 May 20 10:42 ab
-rw-r--r-- 1 root root 0 May 20 10:42 b
[root@mycentos tmp]# touch {a,b}.{1,2}
[root@mycentos tmp]# ls -l
total 32
-rw-r--r-- 1 root root 0 May 20 10:42 a
-rw-r--r-- 1 root root 0 May 20 10:43 a.1
-rw-r--r-- 1 root root 0 May 20 10:43 a.2
-rw-r--r-- 1 root root 0 May 20 10:42 aa
-rw-r--r-- 1 root root 0 May 20 10:42 ab
-rw-r--r-- 1 root root 0 May 20 10:42 b
-rw-r--r-- 1 root root 0 May 20 10:43 b.1
-rw-r--r-- 1 root root 0 May 20 10:43 b.2
[root@mycentos tmp]# cd
[root@mycentos ~]# hostname
mycentos
[root@mycentos ~]# echo " Hostname: "
 Hostname:
[root@mycentos ~]# echo "hostname:`hostname`"
hostname:mycentos
[root@mycentos ~]# echo "hostname:$(hostname)"
hostname:mycentos
[root@mycentos ~]# a=5 b=6 c=7 d=8
[root@mycentos ~]# echo $a $b $c $d
5 6 7 8
[root@mycentos ~]# echo $a+$b+$c
5+6+7
[root@mycentos ~]# echo $($a+$b+$c)========做运算时应用[]
-bash: 5+6+7: command not found
[root@mycentos ~]# echo $[$a+$b+$c]
18
[root@mycentos ~]# echo $[$a * $b]====最好有空格
30
[root@mycentos ~]# echo $[$a/$b]
0
[root@mycentos ~]# echo $[$b/$a]===整除
1
[root@mycentos ~]# echo $[$b%$a]===取余
1
[root@mycentos ~]#
--------------------------------------------------------------------
[root@mycentos ~]# echo your cost is $5.00=====要求显示$5.OO
your cost is .00
[root@mycentos ~]# echo your cost is "$5.00"======双引号不行
your cost is .00
[root@mycentos ~]# echo your cost is \$5.00========\可以
your cost is $5.00
[root@mycentos ~]# echo your cost is '$5.00'=======单引号对所有特殊字符都适用
your cost is $5.00
[root@mycentos ~]# ls \=============指令长的话很好
> -l
total 196
-rwxr-xr-x 1 root root  2023 May 17 11:53 1985calendar
-rw-r--r-- 1 root root  1968 May 17 14:10 1998calendar
-r-Srwsrwt 1 root root  1959 May 17 14:12 1999calendar
-rw------- 1 root root     0 Apr 28 15:04 1.txt
-rw-r--r-- 1 root root     0 May 19 16:03 account.err
-rw------- 1 root root   870 Apr 27 21:49 anaconda-ks.cfg
drwxrwxr-x 2 root root  4096 May 18 15:25 cisco
-rw-r--r-- 1 root root     0 May 19 15:51 ciscobbs
-rw-r--r-- 1 root root    10 May 19 15:58 cisco.out
-rw-r--r-- 1 root root    10 May 19 15:16 cisco.txt
-rw-r--r-- 1 root root     0 May 19 21:40 dstamp
-rw-r--r-- 1 root root    42 May 19 16:02 grep.err
                
      
-----------------------------------------------------------------------      
      
                 quotes
                
single quotes '   inhibit allexpansion
double quotes "   except $ \ . !
[root@mycentos ~]# echo ** 00000 **
20099 5.mp3 a a.1 a.2 aa ab {a.b},{1.2} {a.b}.{1.2} anaconda-ks.cfg b b.1 b.2 install.log install.log.syslog screnn 00000 20099 5.mp3 a a.1 a.2 aa ab {a.b},{1.2} {a.b}.{1.2} anaconda-ks.cfg b b.1 b.2 install.log install.log.syslog screnn
[root@mycentos ~]# echo \*\* 00000 *\*
** 00000 **
[root@mycentos ~]# echo "** 00000 **"
** 00000 **
[root@mycentos ~]# echo '** 00000 **'
** 00000 **
[root@mycentos ~]#
[root@mycentos ~]# echo $a
5
[root@mycentos ~]# echo '$a'
$a
[root@mycentos ~]# echo "$a"=========双引号无法禁止$
5
[root@mycentos ~]# echo \$HOME======要求显示\$HOME
$HOME
[root@mycentos ~]# echo "\$HOME"====双引号无法禁止\
$HOME
[root@mycentos ~]# echo '\$HOME'
\$HOME
[root@mycentos ~]# echo today is `date`========要求显示`date`
today is Wed May 20 10:58:56 CST 2009
[root@mycentos ~]# echo today is "`date`"=====双引号无法禁止``
today is Wed May 20 10:59:12 CST 2009
[root@mycentos ~]# echo today is '`date`'
today is `date`

[root@mycentos ~]# echo '!3'==========双引号无法禁止!
!3
 
 

history================control+r-----------查找历史指令
1064  echo today is `date`
 1065  echo today is "`date`"
 1066  echo today is '`date`'
 1067  echo '!3'
 1068  echo 1
 1069  echo 2
 1070  echo 3
 1071  history
 ctrl+r
 输入关键字e
(reverse-i-search)`e': echo 3
.esc . 
.alt .
[root@mycentos ~]# cal > 1009
[root@mycentos ~]# cat 1009=====先按esc 再.
     April 2009    
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
[root@mycentos ~]#
[root@mycentos ~]# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=5.03 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.42 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.292 ms
--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.292/2.250/5.033/2.021 ms
[root@mycentos ~]# telnet  按下esc . 192.168.1.1==可以将此ip调进来
 
 
[root@mycentos ~]# set -o
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       off
interactive-comments    on
keyword         off
monitor         on
noclobber       off
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off
[root@mycentos ~]# set -o vi========打开vi编辑器
[root@mycentos ~]# set -o
allexport       off
braceexpand     on
emacs           off
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       off
interactive-comments    on
keyword         off
monitor         on
noclobber       off
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              on
xtrace          off
[root@mycentos ~]# -------此时vi模式已打开
echo 2445656676    esc .  dd删除正行 =====在vi打开状态下
set +o vi==============关掉vi模式
set -o emacs===========切换到emacs模式
 
gnome-------------------------
ctrl shift t========产生一个新的标签
ctrl pgup/pgdn=======切换标签
alt   n========指定切换的标签
ctrl shift c/v ========copy/paste
ctrl shift w========关闭标签-terminal

 

本文出自 “www.51cto.com” 博客,谢绝转载!

你可能感兴趣的:(linux,shell,休闲,rche,033)