Bash Shell

通用

如何改变指定用户的登录shell

chsh <用户> -s <新shell>
chsh xiaohui -s /bin/sh

标准输出和错误输出同时重定向到同一位置

方法一:

2>&1 (如# ls /usr/share/doc > out.txt 2>&1 )

方法二:

&> (如# ls /usr/share/doc &> out.txt )

条件判断

if [ 条件 ]
then
命令1
命令2
…..
else
if [ 条件 ]
then
命令1
命令2
….
else
命令1
命令2
…..
fi
fi

比较两个数字

如何测试文件

比如测试文件是否存在:

Last updated