8.1 shell介绍 8.2 命令历史 8.3 命令补全和别名 8.4 通配符 8.5 输入输出重定向

8.1shell介绍

8.2命令历史

8.3命令补全和别名

8.4通配符

8.5输入输出重定向

#Linuxshell基础

#8.1shell介绍
-什么是shell
1.shell是一个命令解释器,提供用户和机器之间的交互
2.支持特定语法,比如逻辑判断、循环
3.每个用户都可以有自己特定的shell
4.CentOS7默认shell为bash(BourneAginShell)
5.还有zsh、ksh等
```
[root@aminglinux-01~]#
[root@aminglinux-01~]#yumlist|grepzsh
autojump-zsh.noarch22.3.0-3.el7epel
zsh.x86_645.0.2-25.el7_3.1updates
zsh-html.x86_645.0.2-25.el7_3.1updates
zsh-lovers.noarch0.9.0-1.el7epel
[root@aminglinux-01~]#yumlist|grepksh
ksh.x86_6420120801-26.el7base
mksh.x86_6446-5.el7base
python-XStatic-Rickshaw.noarch1.5.0.0-4.el7epel
python-moksha-common.noarch1.2.3-2.el7epel
python-moksha-hub.noarch1.4.8-1.el7epel
python-moksha-wsgi.noarch1.2.2-2.el7epel
[root@aminglinux-01~]#
```


#8.2命令历史

![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170814/225032244.png?imageslim)

-很多系统里面的命令都是存在用户的家目录下,/root/.bash_history
```
[root@aminglinux-01~]#ls/root/.bash_history
/root/.bash_history
[root@aminglinux-01~]#cat/root/.bash_history

echo$?
yumlist|grep-iapr
yumlist|grep-ipcre
yuminstall-ypcre.x86_64
yuminstall-ypcre-devel.x86_64
./configure--prefix=/usr/local/apache2
echo$?
make
echo$?
makeinstall
echo$?
ls/usr/local/apache2
init0
[root@aminglinux-01~]#
[root@aminglinux-01~]#echo$HISTSIZE
1000
[root@aminglinux-01~]#
```
-这是我们之前存的命令,这个文件里最大可以存1000条

-histroy-c仅仅是把内存当中的命令给清空了,并不会去删除配置文件
```
[root@aminglinux-01~]#history-c
[root@aminglinux-01~]#history
8history

[root@aminglinux-01~]#cat.bash_history

[root@aminglinux-01~]#ls-l.bash_history
-rw-------.1rootroot158108月1223:03.bash_history
[root@aminglinux-01~]#


```

-变量HISTSIZE可以定义的,在/etc/profile
```
[root@aminglinux-01~]#vi/etc/profile


HOSTNAME=`/usr/bin/hostname2>/dev/null`
HISTSIZE=1000
if["$HISTCONTROL"="ignorespace"];then
exportHISTCONTROL=ignoreboth
else
exportHISTCONTROL=ignoredups
fi

exportPATHUSERLOGNAMEMAILHOSTNAMEHISTSIZEHISTCONTROL

#Bydefault,wewantumasktogetset.Thissetsitforloginshell
#Currentthresholdforsystemreserveduid/gidsis200
#Youcouldcheckuidgidreservationvalidityin
```
-可以把HISTSIZE=1000改为5000保存
```
HOSTNAME=`/usr/bin/hostname2>/dev/null`
HISTSIZE=5000
if["$HISTCONTROL"="ignorespace"];then
exportHISTCONTROL=ignoreboth
else
exportHISTCONTROL=ignoredups
fi

exportPATHUSERLOGNAMEMAILHOSTNAMEHISTSIZEHISTCONTROL

#Bydefault,wewantumasktogetset.Thissetsitforloginshell
#Currentthresholdforsystemreserveduid/gidsis200
#Youcouldcheckuidgidreservationvalidityin
--INSERT--
```
-虽然改了,但是并没有生效
```
[root@aminglinux-01~]#vi/etc/profile
[root@aminglinux-01~]#echo$HISTSIZE
1000
[root@aminglinux-01~]#
```

-使用命令source/etc/profile或者重新进入终端,才会生效
```
[root@aminglinux-01~]#source/etc/profile
[root@aminglinux-01~]#echo$HISTSIZE
5000
[root@aminglinux-01~]#

```
-会记录日期时间,这个效果是由环境变量改变的,但是只是在当前终端下生效,
```
[root@aminglinux-01~]#history
8history
9cat.bash_history
10ls-l.bash_history
11vi/etc/profile
12echo$HISTSIZE
13source/etc/profile
14echo$HISTSIZE
15history
[root@aminglinux-01~]#

改变命令历史的格式
[root@aminglinux-01~]#HISTTIMEFORMAT="%Y/%m/%d%H:%M:%S"
[root@aminglinux-01~]#echo$HISTTIMEFORMAT
%Y/%m/%d%H:%M:%S
[root@aminglinux-01~]#history
82017/08/1423:07:03history
92017/08/1423:09:09cat.bash_history
102017/08/1423:10:08ls-l.bash_history
112017/08/1423:28:55vi/etc/profile
122017/08/1423:33:10echo$HISTSIZE
132017/08/1423:34:10source/etc/profile
142017/08/1423:34:13echo$HISTSIZE
152017/08/1423:35:40history
162017/08/1423:39:00HISTTIMEFORMAT="%Y/%m/%d%H:%M:%S"
172017/08/1423:39:15echo$HISTTIMEFORMAT
182017/08/1423:39:28history
[root@aminglinux-01~]#
```

-改变命令历史的格式,这个只针对当前终端下生效,如果想要所有的都生效,需要编辑vi/etc/profile文件把HISTTIMEFORMAT="%Y/%m/%d%H:%M:%S"加入到文件里面vi/etc/profile

```
HOSTNAME=`/usr/bin/hostname2>/dev/null`
HISTSIZE=5000
HISTTIMEFORMAT="%Y/%m/%d%H:%M:%S"加入这一行

if["$HISTCONTROL"="ignorespace"];then
exportHISTCONTROL=ignoreboth
else
exportHISTCONTROL=ignoredups


[root@aminglinux-01~]#vi/etc/profile
[root@aminglinux-01~]#source!$
source/etc/profile
[root@aminglinux-01~]#
```
-这时候再打开另一个终端就可以看到生效了
![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170814/234805048.png?imageslim)

```
[root@aminglinux-01~]#echo$HISTTIMEFORMAT
%Y/%m/%d%H:%M:%S
[root@aminglinux-01~]#
9872017/08/1423:46:55echo$?
9882017/08/1423:46:55yumlist|grep-iapr
9892017/08/1423:46:55yumlist|grep-ipcre
9902017/08/1423:46:55yuminstall-ypcre.x86_64
9912017/08/1423:46:55yuminstall-ypcre-devel.x86_64
9922017/08/1423:46:55./configure--prefix=/usr/local/apache2
9932017/08/1423:46:55echo$?
9942017/08/1423:46:55make
9952017/08/1423:46:55echo$?
9962017/08/1423:46:55makeinstall
9972017/08/1423:46:55echo$?
9982017/08/1423:46:55ls/usr/local/apache2
9992017/08/1423:46:55init0
10002017/08/1423:46:57clear
10012017/08/1423:47:07echo$HISTTIMEFORMAT
10022017/08/1423:48:13history
[root@aminglinux-01~]#

```
-改变命令历史的格式就成功了

-永久保存命令历史chattr+a~/.bash_history
```
[root@aminglinux-01~]#chattr+a~/.bash_history
```
-这样运行过的命令都会记录下来,
-但是如果不正常退出,有时候敲了一些命令,但是你没有logout,exit退出,而是直接关闭终端,那样就会记录不全,命令就保存的不全。

-命令!!2个!其实就是你运行的上一条命令(最后一条命令)
```
[root@aminglinux-01~]#ls
1111_heard.txt1.txt~2343.txtanaconda-ks.cfg.1
1231_sorft.txt1.txt.bak2.txt.bak4.txtbiji.txt
[root@aminglinux-01~]#!!
ls
1111_heard.txt1.txt~2343.txtanaconda-ks.cfg.1
1231_sorft.txt1.txt.bak2.txt.bak4.txtbiji.txt
[root@aminglinux-01~]#
```
-!n表示运行history里面的第n条命令
```
[root@aminglinux-01~]#history
82017/08/1423:07:03history
92017/08/1423:09:09cat.bash_history
102017/08/1423:10:08ls-l.bash_history
112017/08/1423:28:55vi/etc/profile
122017/08/1423:33:10echo$HISTSIZE
132017/08/1423:34:10source/etc/profile
142017/08/1423:34:13echo$HISTSIZE
152017/08/1423:35:40history
162017/08/1423:39:00HISTTIMEFORMAT="%Y/%m/%d%H:%M:%S"
172017/08/1423:39:15echo$HISTTIMEFORMAT
182017/08/1423:39:28history
192017/08/1423:43:15vi/etc/profile
202017/08/1423:45:50source/etc/profile
212017/08/1423:51:50chattr+a~/.bash_history
222017/08/1423:54:18history
232017/08/1423:55:50ls
242017/08/1423:56:13history
[root@aminglinux-01~]#!10
ls-l.bash_history
-rw-------.1rootroot158818月1423:51.bash_history
[root@aminglinux-01~]#
```
-!word它会在命令历史里面倒着往上找第一个有word的命令
-比如运行命令!echo就是运行命令历史里倒着数第一个有ehco相关的命令
```
[root@aminglinux-01~]#history
82017/08/1423:07:03history
92017/08/1423:09:09cat.bash_history
102017/08/1423:10:08ls-l.bash_history
112017/08/1423:28:55vi/etc/profile
122017/08/1423:33:10echo$HISTSIZE
132017/08/1423:34:10source/etc/profile
142017/08/1423:34:13echo$HISTSIZE
152017/08/1423:35:40history
162017/08/1423:39:00HISTTIMEFORMAT="%Y/%m/%d%H:%M:%S"
172017/08/1423:39:15echo$HISTTIMEFORMAT
182017/08/1423:39:28history
192017/08/1423:43:15vi/etc/profile
202017/08/1423:45:50source/etc/profile
212017/08/1423:51:50chattr+a~/.bash_history
222017/08/1423:54:18history
232017/08/1423:55:50ls
242017/08/1423:56:13history
[root@aminglinux-01~]#!10
ls-l.bash_history
-rw-------.1rootroot158818月1423:51.bash_history
[root@aminglinux-01~]#!echo
echo$HISTTIMEFORMAT
%Y/%m/%d%H:%M:%S
[root@aminglinux-01~]#
```
-命令历史里关于ehco的命令是echo$HISTTIMEFORMAT%Y/%m/%d%H:%M:%S,所以!echo就是运行这个命令echo$HISTTIMEFORMAT%Y/%m/%d%H:%M:%S



#8.3命令补全和别名
![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170815/220451944.png?imageslim)

-按tab一下补全命令,tab按俩下列出以命令开头的命令
```
[root@aminglinux-01~]#ls
lslsblklsinitrdlslockslsmodlspci
lsattrlscpulsipclsloginslsnslsscsi
[root@aminglinux-01~]#mk
mkdictmkfifomkfs.ext2mkfs.xfsmknod
mkdirmkfsmkfs.ext3mkhomedir_helpermkpasswd
mkdumprdmkfs.btrfsmkfs.ext4mkinitrdmkswap
mke2fsmkfs.cramfsmkfs.minixmklost+foundmktemp
[root@aminglinux-01~]#mktemp
```
-运行mktab俩下就会显示一堆以mk开头的命令,按mkttab一下就会自动补全mktemp
-centos7里面支持参数补全
1.需要安装一个包
```
[root@aminglinux-01~]#systemctlrestartnetwork^C
[root@aminglinux-01~]#yuminstall-ybash-completion

已安装:
bash-completion.noarch1:2.1-6.el7
完毕!
[root@aminglinux-01~]#
```
2.安装完需要重启下系统才可以reboot或者init6
3.重启系统之后,先看下那个包是否安装,然后输入部分命令尝试按下tab看看是否会补全
```
[root@aminglinux-01~]#rpm-qabash-completion
bash-completion-2.1-6.el7.noarch
[root@aminglinux-01~]#systemctlres
rescuereset-failedrestart
[root@aminglinux-01~]#systemctlres
rescuereset-failedrestart
[root@aminglinux-01~]#systemctlres
rescuereset-failedrestart
[root@aminglinux-01~]#systemctlrestartnetwork
network-online.targetnetwork.service
[root@aminglinux-01~]#systemctlrestartnetwork.service
[root@aminglinux-01~]#
```
-alias别名给名重新起个名字用alias把systemctlrestartnetwork.service改为restartnet
```
[root@aminglinux-01~]#systemctlrestartnetwork.service
[root@aminglinux-01~]#aliasrestartnet='systemctlrestartnetwork.service'
[root@aminglinux-01~]#restartnet

把系统里所有的alias都列出来
[root@aminglinux-01~]#alias
aliascp='cp-i'
aliasegrep='egrep--color=auto'
aliasfgrep='fgrep--color=auto'
aliasgrep='grep--color=auto'
aliasl.='ls-d.*--color=auto'
aliasll='ls-l--color=auto'
aliasls='ls--color=auto'
aliasmv='mv-i'
aliasrestartnet='systemctlrestartnetwork.service'
aliasrm='rm-i'
aliaswhich='alias|/usr/bin/which--tty-only--read-alias--show-dot--show-tilde'
[root@aminglinux-01~]#
```
-取消自定义别名
```
[root@aminglinux-01profile.d]#unaliasrestartnet
[root@aminglinux-01profile.d]#restartnet
-bash:restartnet:未找到命令
[root@aminglinux-01profile.d]#
```

-这些alias存在哪里呢.bashrc,/etc/profile.d
```
[root@aminglinux-01~]#vi.bashrc

#.bashrc

#Userspecificaliasesandfunctions

aliasrm='rm-i'
aliascp='cp-i'
aliasmv='mv-i'

#Sourceglobaldefinitions
if[-f/etc/bashrc];then
./etc/bashrc
fi
~
~
```
2.这个/etc/profile.d文件下面的colorls.sh,colorgrep.sh也有
```
[root@aminglinux-01~]#cd/etc/profile.d
[root@aminglinux-01profile.d]#ls
256term.cshcolorgrep.cshcolorls.shless.cshvim.sh
256term.shcolorgrep.shlang.cshless.shwhich2.csh
bash_completion.shcolorls.cshlang.shvim.cshwhich2.sh
[root@aminglinux-01profile.d]#vicolorls.sh
~
".bashrc"12L,176C



aliasll='ls-l'2>/dev/null
aliasl.='ls-d.*'2>/dev/null

INCLUDE=
COLORS=

forcolorsin"$HOME/.dir_colors.$TERM""$HOME/.dircolors.$TERM"\
"$HOME/.dir_colors""$HOME/.dircolors";do
[-e"$colors"]&&COLORS="$colors"&&\
INCLUDE="`/usr/bin/cat"$COLORS"|/usr/bin/grep'^INCLUDE'|/usr/bin/cut-d''-f2-`"&&\
break
done

/alias
```
3.colorgrep.sh文件也有
```
#color-grepinitialization

/usr/libexec/grepconf.sh-c||return

aliasgrep='grep--color=auto'2>/dev/null
aliasegrep='egrep--color=auto'2>/dev/null
aliasfgrep='fgrep--color=auto'2>/dev/null
~

"colorgrep.sh"7L,201C
```


#8.4通配符
![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170815/223720549.png?imageslim)

-*.txt*表示任何字符
```
[root@aminglinux-01~]#ls
1111_heard.txt1.txt~2343.txtanaconda-ks.cfg.1
1231_sorft.txt1.txt.bak2.txt.bak4.txtbiji.txt
[root@aminglinux-01~]#ls*.txt
1_heard.txt1_sorft.txt3.txt4.txtbiji.txt
[root@aminglinux-01~]#ls*txt
1_heard.txt1_sorft.txt3.txt4.txtbiji.txt
[root@aminglinux-01~]#ls*txt*
1_heard.txt1_sorft.txt1.txt~1.txt.bak2.txt.bak3.txt4.txtbiji.txt
[root@aminglinux-01~]#ls1*
1_heard.txt1_sorft.txt1.txt~1.txt.bak

111:
12.tx~12.txt12_txt.swp2224913aming3

123:
aminglinux.logyum.log
[root@aminglinux-01~]#
```
-ls?.txt?表示一个字符任意的字符
```
[root@aminglinux-01~]#touch2.txt
[root@aminglinux-01~]#touch1.txt
[root@aminglinux-01~]#ls?.txt
1.txt2.txt3.txt4.txt
[root@aminglinux-01~]#toucha.txt
[root@aminglinux-01~]#touchbb.txt
[root@aminglinux-01~]#ls?.txt
1.txt2.txt3.txt4.txta.txt
[root@aminglinux-01~]#
```
-ls[0-9].txt[]13.txt或者的意思
```
[root@aminglinux-01~]#ls[0-3].txt
1.txt2.txt3.txt
[root@aminglinux-01~]#ls[123].txt
1.txt2.txt3.txt
[root@aminglinux-01~]#ls[23].txt
2.txt3.txt
[root@aminglinux-01~]#ls[13].txt
1.txt3.txt
[root@aminglinux-01~]#ls[0-9].txt
1.txt2.txt3.txt4.txt
[root@aminglinux-01~]#ls[0-9a-zA-Z].txt
1.txt2.txt3.txt4.txta.txt
[root@aminglinux-01~]#
```
-ls{1,2}.txt
```
[root@aminglinux-01~]#ls{1,2}.txt
1.txt2.txt
[root@aminglinux-01~]#ls{1,2,3,a}.txt
1.txt2.txt3.txta.txt
[root@aminglinux-01~]#
```

##8.5输入输出重定向

-[]>正确的输出重定向cat1.txt>2.txt
-[]>>正确的追加cat1.txt>>2.txt
-2>错误的输出重定向lsaaa.txt2>err
-2>>错误的追加lsaaa.txt2>>err

```
[root@aminglinux-01~]#lsaaa
-bash:lsaaa:未找到命令
[root@aminglinux-01~]#lsaaa2>a.txt
[root@aminglinux-01~]#cata.txt
-bash:lsaaa:未找到命令
[root@aminglinux-01~]#lsaaa2>>a.txt
[root@aminglinux-01~]#cata.txt
-bash:lsaaa:未找到命令
-bash:lsaaa:未找到命令
[root@aminglinux-01~]#>>>2>2>>>+2>==&>^C
[root@aminglinux-01~]#
```
-&>可以把正确和错误的放一起
```
[root@aminglinux-01~]#ls[12].txtaaa.txt&>a.txt
[root@aminglinux-01~]#cata.txt
ls:无法访问aaa.txt:没有那个文件或目录
1.txt
2.txt
[root@aminglinux-01~]#
```
-&>同样也支持追加
```
[root@aminglinux-01~]#ls[12].txtaaa.txt&>>a.txt
[root@aminglinux-01~]#cata.txt
ls:无法访问aaa.txt:没有那个文件或目录
1.txt
2.txt
ls:无法访问aaa.txt:没有那个文件或目录
1.txt
2.txt
[root@aminglinux-01~]#
```
-&>既可以放正确也可以发个错误的输出信息保存到指定的文件里
```
[root@aminglinux-01~]#ls[12].txtaaa.txt>1.txt2>a.txt
[root@aminglinux-01~]#cat1.txt
1.txt
2.txt
[root@aminglinux-01~]#cata.txt
ls:无法访问aaa.txt:没有那个文件或目录
[root@aminglinux-01~]#
```
-输入重定向把右边的一个文件,文件的内容给它左边输入到一个命令里面去
```
[root@aminglinux-01~]#wc-l<1.txt
2
[root@aminglinux-01~]#2.txt<1.txt
-bash:2.txt:未找到命令
[root@aminglinux-01~]#
```
-[]左边必须是一个命令,不可以是文件输入重定向用的比较少,做一个了解

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2280端口映射到公网,发现经常被暴力破解,自己写了个临时封禁ip功能的脚本,实现5分钟内同一个ip登录密码错误10次就封禁这个ip5分钟,并且进行邮件通知使用步骤openwrt为19.07.03版本,其他版本没有测试过安装bashmsmtpopkg
#!/bin/bashcommand1&command2&wait从Shell脚本并行运行多个程序–杨河老李(kviccn.github.io)
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/phpls-ls 2.编辑修改.bash_profile文件(没有.bash_profile文件的情况下回自动创建)sudovim~/.bash_profile在文件的最后输入以下信息,然后保存退出exportPATH="/Applications/MAMP/bin/php/php7.2.20/b
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如zh_CN之类的语言包,进行中文语言包装:apt-getinstalllanguage-pack-zh-hans3、安装好后我们可以进行临时修改:然后添加中文支持: locale-genzh_CN.UTF-8临时修改> export LC_ALL='zh_CN.utf8'> locale永久
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexadecimalbash2#[0~1]0[0~7]0x[0~f]or0X[0~f]perl0b[0~1]0[0~7]0x[0~f]tcl0b[0~1]0o[0~7]0x[0~f]bashdifferentbaserepresntationreference2.StringlengthLanguageStr
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全命令补全方法:yum-yinstallbash-completionsource/usr/share/bash-completion/bash_completionsource<(kubectlcompletionbash)echo"source<(kubectlcompletionbash)">>~/.bashrc 
参考这里启动jar包shell脚本修改过来的#!/bin/bash#默认应用名称defaultAppName='./gadmin'appName=''if[[$1&&$1!=0]]thenappName=$1elseappName=$defaultAppNamefiecho">>>>>>本次重启的应用:$appName<
#一个数字的行#!/bin/bashwhilereadlinedon=`echo$line|sed's/[^0-9]//g'|wc-L`if[$n-eq1]thenecho$linefidone<1.txt#日志切割归档#!/bin/bashcd/data/logslog=1.logmv_log(){[-f$1]&&mv$1$2
#文件增加内容#!/bin/bashn=0cat1.txt|whilereadlinedon=[$n+1]if[$n-eq5]thenecho$lineecho-e"#Thisisatestfile.\n#Testinsertlineintothisfile."elseecho$linefidone#备份/etc目录#
# su - oraclesu: /usr/bin/ksh: No such file or directory根据报错信息:显示无法找到文件 /usr/bin/ksh果然没有该文件,但是发现存在文件/bin/ksh,于是创建了一个软连接,可以规避问题,可以成功切换到用户下,但无法执行系统自带命令。$. .bash_profile-ksh: .: .b
history显示历史指令记录内容,下达历史纪录中的指令主要的使用方法如果你想禁用history,可以将HISTSIZE设置为0:#exportHISTSIZE=0使用HISTIGNORE忽略历史中的特定命令下面的例子,将忽略pwd、ls、ls-ltr等命令:#exportHISTIGNORE=”pwd:ls:ls-ltr:”使用HIS
一.命令历史  1.history环境变量:    HISTSIZE:输出的命令历史条数,如history的记录数    HISTFILESIZE:~/.bash_history保存的命令历史记录数    HISTFILLE:历史记录的文件路径    HISTCONTROL:     ignorespace:忽略以空格开头的命令
之前在网上看到很多师傅们总结的linux反弹shell的一些方法,为了更熟练的去运用这些技术,于是自己花精力查了很多资料去理解这些命令的含义,将研究的成果记录在这里,所谓的反弹shell,指的是我们在自己的机器上开启监听,然后在被攻击者的机器上发送连接请求去连接我们的机器,将被攻击者的she
BashOne-LinersExplained,PartI:Workingwithfileshttps://catonmat.net/bash-one-liners-explained-part-oneBashOne-LinersExplained,PartII:Workingwithstringshttps://catonmat.net/bash-one-liners-explained-part-twoBashOne-LinersExplained,PartII
Shell中变量的作用域:在当前Shell会话中使用,全局变量。在函数内部使用,局部变量。可以在其他Shell会话中使用,环境变量。局部变量:默认情况下函数内的变量也是全局变量#!/bin/bashfunctionfunc(){a=99}funcecho$a输出>>99为了让全局变量变成局部变量
1、多命令顺序执行;  命令1;命令2  多个命令顺序执行,命令之间没有任何逻辑联系&&  命令1&&命令2  逻辑与,当命令1正确执行,才会执行命令2||  命令1||命令2  逻辑或,当命令1执行不正确,才会执行命令2例如:ls;date;cd/home/lsx;pwd;who ddif=输入文件of=输
原博文使用Linux或者unix系统的同学可能都对#!这个符号并不陌生,但是你真的了解它吗?首先,这个符号(#!)的名称,叫做"Shebang"或者"Sha-bang"。Linux执行文件时发现这个格式,会把!后的内容提取出来拼接在脚本文件或路径之前,当作实际执行的命令。 Shebang这个符号通常在Unix系统的脚本
1、历史命令history[选项][历史命令保存文件]选项:-c:  清空历史命令-w:  把缓存中的历史命令写入历史命令保存文件 ~/.bash_historyvim/etc/profile中的Histsize可改存储历史命令数量历史命令的调用使用上、下箭头调用以前的历史命令使用“!n”重复执行第n条历史
目录1.Shell脚本规范2.Shell脚本执行3.Shell脚本变量3.1环境变量3.1.1自定义环境变量3.1.2显示与取消环境变量3.1.3环境变量初始化与对应文件的生效顺序3.2普通变量3.2.1定义本地变量3.2.2shell调用变量3.2.3grep调用变量3.2.4awk调用变量3.3
   http://www.voidcn.com/blog/wszzdanm/article/p-6145895.html命令功能:显示登录用户的信息命令格式:常用选项:举例:w显示已经登录的用户及正在进行的操作[root@localhost~]#w 11:22:01up4days,21:22, 3users, loadaverage:0.00,0.00,0.00USER