Conditional Logic on Files # 判断文件是否存在及文件类型 -a file exists. #文件存在 -b file exists and is a block special file. #文件存在,并且是块设备 -c file exists and is a character special file. ##文件存在,并且是字符设备 -d file exists and is a directory. #文件存在,并且是目录 -e file exists (ju…
概述 shell中常见命令history 历史纪录命令:history 命令格式如下: [root@localhost ~]# history [选项] [历史命令保存文件] -c:清空历史命令: -w:把内存中的命令直接写入 ~/.bash_history 文件中 查询系统中当前用户的所有历史命令 [root@localhost ~]# history ls cd / ls poweroff -h now poweroff h now poweroff whereis ls …省略部分输出……
本文主要讲bash脚本中容易出错和很少用但是用起来有意想不到效果的部分. 循环: 正常的for循环: for i in a b c 1 2 3; do echo "$i" done 数字序列循环: `; do echo "$i" done 其中的 `` 也可以换成 {..} {开始..结尾}的这种形式可以表示连续的数列,可以从小到大也可以从大到小,但是可惜不像python的range()那样可以指定间隔量 C语言风格的for循环: ; i<; i++ ));…