Linux shell入门基础(五)

五、bash运算及启动脚本
01.使用bash的命令历史
#history
……
#set(显示所有的变量) | grep HIS
HISTFILE=/root/.bash_history
HISTFILESIZE=1000(历史文件个数)
HISTSIZE=1000(文件的历史大小)
#vi /root/.bash_history
……(1016)
#exit(保存最新的1000个命令)
#history -c(清除历史命令)
不同的console中保存各自的bash命令
#vi .bash_logout
#~/.bash_logout
clear
history -c(退出控制台后,彻底清空bash命令)
:wq
#
#Ctrl+r
(reverse-i-search)'mount -t':mount -t proc none /mnt
输入印象中的前几个字母即可出现整行命令
#history
……
#!213
#!!(上一条命令)
02.bash的变量类型
#AA=aaaaaa
#set |grep AA
AA=aaaaaa
#env AA(显示AA的环境变量)
#export AA(改变AA的环境变量)
#set | grep AA
AA=aaaaaa
alis别名
#alis ooo=HHHHHHHH
#echo ooo
HHHHHHHH
03.bash中的运算符
#!20执行第20条命令
#!!执行上一条命令
#!$ 上一条命令的最后一个参数
#$求出某个变量的值
#*表示任意多个任意字符的文件名
#echo ???文件名的一部分三个字符
#echo [abc]*  abc开头的文件名
#tauch {a,b,c}-{a,b,c}(表示枚举)
#ls -l
touch 36
-rw-r--r-- 1 root root 0 jul 2 11:09 a-1
-rw-r--r-- 1 root root 0 jul 2 11:09 a-2
-rw-r--r-- 1 root root 0 jul 2 11:09 a-3
-rw-r--r-- 1 root root 0 jul 2 11:09 b-1
-rw-r--r-- 1 root root 0 jul 2 11:09 b-2
-rw-r--r-- 1 root root 0 jul 2 11:09 b-3
-rw-r--r-- 1 root root 0 jul 2 11:09 c-1
-rw-r--r-- 1 root root 0 jul 2 11:09 c-2
-rw-r--r-- 1 root root 0 jul 2 11:09 c-3
#&(丢入后台的命令)
#~主目录
#cd ~byf
[root@byf]#
#aaa()
>{
>echo this is aaa
>ls
>cd /tmp
>touch /tmp/ddd/a
>}
#aaa
#touch a b(a,b间的空格,如果a,b不加双引号时,表示参数结束)
#ls 
a
a b
b
#touch "a b"
#ls
a b
#touch 'a b $USER'
(单引号屏蔽所有的符号)
#ls -l
a b $USER
#touch "a b  $USER"
#ls -l
a b root
#echo `which ls`
alias ls='ls --color=try' /bin/ls
#echo which ls
which ls
#touch log`date+%y%m%d`(年月日)
#ls 
log160310
#rm a\ (转义字符)b
(删去单个文件“a b”)
#echo $?
上一条命令是否为假
#[-f /etc/passwd] &&(前边的命令为真的时候执行后边的命令) echo ok
#[-f (文件)passwd /etc/passwddddd] || echo ok
ok
#[-d(是不是目录) /orical] && echo begin the install
(如果指定文件存在,返回结果begin the install)
#-l(链接) -b(block) -c(字符) -x(执行) -r(读) -w(写)
#[$USER =root] && echo hello root
hello root
0.4定制bash
/etc/profile(全体成员配置)
~/.bash_profile(个人配置)
~/.bashrc(个人配置)
/etc/bashrc(全体成员配置)
#ifconnfig
cannot find:……
#vi /etc/profile
(添加新的语句)
PATH=$PATH:/sbin(增加环境变量)
#ifconfig
cannot find:……
#exit
#su byf
#ifcongfig
eth0:
lo:
(修改后,要记得还原)
#vi /etc/bashrc
#exit(执行~/.bash_logout)
#vi ~/bashrc
增加
export LANG="zh_CN.UTF-8"
export LC_ALL="zh_CN.UTF-8"
alt+f1
# su root
#echo $LANG
zh_CN.UTF-8
#start -- : 1(切换到中文版的linux)
Ctrl+f7回到原来的界面
#vi /exc/sysconfig/i18n
也可以实现上述功能,修改整个系统
#export LANG=zh_CN.UTF-8
posted @ 2016-03-10 16:17  AsuraDoyle  阅读(272)  评论(0编辑  收藏  举报