#bash shell 和 其他shell useradd -s 参数 yum -y install ksh zsh tcsh [aaa@localhost ~]$ ls /dev/stdin -l lrwxrwxrwx. 1 root root 15 7月 23 22:03 /dev/stdin -> /proc/self/fd/0 #stdin标准输入 [aaa@localhost ~]$ ls /dev/stdout -l lrwxrwxrwx. 1 root root 15 7月 23 22:03 /dev/stdout -> /proc/self/fd/1 #stdout即输出到屏幕 [aaa@localhost ~]$ ls /dev/stderr -l lrwxrwxrwx. 1 root root 15 7月 23 22:03 /dev/stderr -> /proc/self/fd/2 #stderr标准错误 特殊设备 /dev/null 黑洞 ls > file.1 #标准输出 重定向到 file.1文件 ls >> file.1 #标准输出 追加到 file.1文件 ls | tee file.1 # 一式二份 标准输出一份,file.1一份 ls | tee -a file.1 # 一式二份 标准输出一份 追加file.1一份 -a append bash aa.sh | tee -a file.1 bash aa.sh 2>&1 | tee -a file.1 #最常用 # 标准错误和标准输出 都输出到屏幕,并且追加一份到file.1 ls /root >out.log 2>err.log #标准输出重定向到 out.log 标准错误重定向到 err.log ls /root >>out.log 2>>err.log ls /root/ 2>&1 | tee -a out.log ls /root/ >/dev/null 2>&1 # 标准错误 重定向到标准输出, 再次标准输出重定向到 /dev/null #man bash可以查看 command 2> file.1 #标准错误重定向到 file.1 command &> file.1 #标准输出重定向到file.1 即标准错误和标准输出 重定向到 file.1 command 2>> file.1 command &>> file.1 # touch > >> vi tee cat 都可以创建文件 < #重定向输入 # 从指定的文件输入数据 passwd --stdin aaa < pass.txt #在bash脚本里面 使用sfdisk 划分磁盘分区。 sfdisk -d /dev/sda > hda.out # -d == --dump sfdisk --dump /dev/sda > hda.out sfdisk /dev/sdb < hda.out #把 /dev/sdb分区 做成和 /dev/sda一样的分区 # 变量,环境变量 $PATH $LANG $HOME $USER 查看 环境变量的命令 env