五、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入门基础(五)的更多相关文章

  1. Linux shell入门基础(六)

    六.Shell脚本编程详解 将上述五部分的内容,串联起来,增加对Shell的了解 01.shell脚本 shell: # #perl #python #php #jsp 不同的脚本执行不同的文本,执行 ...

  2. Linux shell入门基础(一)

    Linux shell入门基础(一): 01.增加删除用户: #useradd byf   userdel byf(主目录未删除)  userdel -r byf   该用户的属性:usermod 用 ...

  3. Linux shell入门基础(八)

    八.shell脚本sed&awk 01.sed的使用 流编辑器-Steam Editor #ed /etc/passwd 1,10p …… 1s/root/byf/p(替换root为byf) ...

  4. Linux shell入门基础(三)

    三.输入输出重定向及管道 01.过滤器   Linux过滤器分三种:     1.过滤器(重定向只对过滤器有作用) #gzip a(将a作为输入源,涉及到输入输出)     2.编辑器     3.交 ...

  5. Linux shell入门基础(二)

    二.shell对文本的操作 01.查看文本的命令 #cat /etc/passwd(并非对文本文件操作) #tail -5 /etc/passwd(查看末尾5行) #tail -f /var/log/ ...

  6. Linux shell入门基础(七)

    七.bash脚本中的流程控制   条件判断控制   -[]([]中的表达式是否为真)  &&(前边的结果是true的时候执行后边的命令)   ||(前边的结果是false的时候执行后边 ...

  7. Linux shell入门基础(四)

    四.进程优先级前台后台 01.进程控制 #find /name aaa & #ps aux | grep find #updatedb &  #ps aux | grep update ...

  8. 1)Linux程序设计入门--基础知识

    )Linux程序设计入门--基础知识 Linux下C语言编程基础知识 前言: 这篇文章介绍在LINUX下进行C语言编程所需要的基础知识.在这篇文章当中,我们将 会学到以下内容: 源程序编译 Makef ...

  9. linux shell 入门

    本文是本人学习linux shell入门收集整理,不完全原创. 参考博文: http://www.cnblogs.com/suyang/archive/2008/05/18/1201990.html ...

随机推荐

  1. jquery 实现的一款超简单的图片切换功能

    <html><head> <meta http-equiv="Content-Type" content="text/html; chars ...

  2. adb设备,根据serial获取vid pid

    使用adb devices命令,可以轻松获取到所有连接到PC的adb设备的serial值. 但是adb命令无法获取adb usb设备的vendor id和product id. 本程序根据adb协议, ...

  3. 1. android

    http://blog.csdn.net/mirkerson/article/details/7238815

  4. avi文件格式详解【转】

    AVI是音频视频交错(Audio Video Interleaved)的英文缩写,它是Microsoft公司开发的一种符合RIFF文件规范的数字音频与视频文件格式,原先用于Microsoft Vide ...

  5. js singleton

    方案一:利用闭包的两个作用,可以变通地读到内部的变量. 方案二: 是可以让这些变量始终在内存中. 方案一 var SingletonTester = (function () { //单例方法 fun ...

  6. AsyncCalls – Asynchronous function calls

    AsyncCalls – Asynchronous function callsWith AsyncCalls you can execute multiple functions at the sa ...

  7. Timus1132(二次剩余方程求解)

    题目:http://acm.timus.ru/problem.aspx?space=1&num=1132 题意:就是给出方程,p为素数,求在区间内的解. 这个思路很简单,详见:http://a ...

  8. 网络流(最大费用最大流) :POJ 3680 Intervals

    Intervals Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7218   Accepted: 3011 Descrip ...

  9. 【中途相遇法】【STL】BAPC2014 K Key to Knowledge (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  10. Hierarchy Viewer显示视图性能指标

    Hierarchy Viewer默认打开“Tree View”窗口无法显示显示Performance indicators: 但选中根视图再点击按钮“Obtain layout times for t ...