Shell编程shell学习 基础(1)#!/bin/bash #for.sh for i in a b c d do echo $i sleep done 设置权限 chmod a+x for.sh 不设去权限使用 bash ./for.sh 执行 tab自动补全 demo:设置网卡ip vi /etc/sysconfig/network-scripts/ifcfg-eth0 命令历史 hist作者王明昌发布时间2019-04-08复制 #!/bin/bash #for.sh for i in a b c d do echo $i sleep done 设置权限 chmod a+x for.sh 不设去权限使用 bash ./for.sh 执行 tab自动补全 demo:设置网卡ip vi /etc/sysconfig/network-scripts/ifcfg-eth0 命令历史 history !5 历史中的第五条命令 !ser 历史中最后一条以ser开头的命令 命令别名 df -Th 查看磁盘大小 alias 查看别名 alias ddd = 'df -Th' 设置别名 永久保存 当前用户下的bashrc中添加 输出重定向 结果输出到文件 ifconfig eth0 > net.txt 保存覆盖 结果输出到文件 ifconfig eth0 >> net.txt 保存追加 结果输出到文件 ifconfig eth0 2> net.txt 错误重定向(前面命令错误,将结果输出到后面) 结果输出到文件 ifconfig eth0 2>> net.txt 错误重定向(前面命令错误,将结果输出到后面) 追加 结果输出到文件 bash red.sh &> net.txt 正确+错误命令(不能追加) 结果输出到文件 bash red.sh 1>> net.txt 2>&1 正确+错误命令(追加) (错误的输出给了1的通道) 管道操作 free -m 查看内存(以m为单位)
2019-11-27shell学习初体验centos7支持的shell cat /etc/shells c7默认shell echo $SHELL /bin/bash shell变量 1. 全局变量(环境变量) echo $PS1 echo
2019-04-08shell学习 基础(2)linux权限用户权限 drwxr-xr-x root root -rw-r--r-- root root 解析: d 目录 - 文件 root 用户 root 用户组 rw- root所有者 r-- root所属