星空网 > 软件开发 > 操作系统

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




原标题:Linux shell入门基础(五)

关键词:linux

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

蜂巢跨境:https://www.goluckyvip.com/tag/31455.html
蜂大侠:https://www.goluckyvip.com/tag/31456.html
蜂俱网:https://www.goluckyvip.com/tag/31457.html
蜂卖通:https://www.goluckyvip.com/tag/31458.html
蜂鸟Lazada:https://www.goluckyvip.com/tag/31459.html
仿品规则:https://www.goluckyvip.com/tag/3146.html
咸阳机场到临潼景点 西安咸阳机场到临潼有多远:https://www.vstour.cn/a/411236.html
合肥有什么约会的地方好玩的地方 合肥哪里适合情侣好玩的地方:https://www.vstour.cn/a/411237.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流