开场白:这里简单记录一些常用的bash命令,一则备忘,二来希望可以帮助别人解决一些问题. 1.检测文件是否存在 if [ -f ./foo.txt ] then echo the file exists fi 2. 检测目录是否存在 if [ -d ./test1 ] then echo the directory exists fi 3. 让高亮功能一直存在 androidyue@ubuntu:~/Desktop$ ls | grep s --color=always | more 4.使用c
Shell echo命令 echo "It is a test" 这里的双引号完全可以省略 .显示变量 read 命令从标准输入中读取一行,并把输入行的每个字段的值指定给 shell 变量 #!/bin/sh read name echo "$name It is a test" $ OK #标准输入 $ OK It is a test #输出 显示不换行 #!/bin/sh echo -e "OK! \c" # -e 开启转义 \c 不换行 e