linux shell命令例子linux bash命令用法shell符号解释
2017-02-07 09:10
716 查看
Linux SHELL if 命令参数说明
UNIX Shell 里面比较字符写法:
下面是我linux的脚本例子。用于编译嵌入式程序,编译好之后,把程序通过ssh拷贝到开发板:
* –b 当file存在并且是块文件时返回真 * -c 当file存在并且是字符文件时返回真 * -d 当pathname存在并且是一个目录时返回真 * -e 当pathname指定的文件或目录存在时返回真 * -f 当file存在并且是正规文件时返回真 * -g 当由pathname指定的文件或目录存在并且设置了SGID位时返回为真 * -h 当file存在并且是符号链接文件时返回真,该选项在一些老系统上无效 * -k 当由pathname指定的文件或目录存在并且设置了“粘滞”位时返回真 * -p 当file存在并且是命令管道时返回为真 * -r 当由pathname指定的文件或目录存在并且可读时返回为真 * -s 当file存在文件大小大于0时返回真 * -u 当由pathname指定的文件或目录存在并且设置了SUID位时返回真 * -w 当由pathname指定的文件或目录存在并且可执行时返回真。一个目录为了它的内容被访问必然是可执行的。 * -o 当由pathname指定的文件或目录存在并且被子当前进程的有效用户ID所指定的用户拥有时返回真。
UNIX Shell 里面比较字符写法:
* -eq 等于 * -ne 不等于 * -gt 大于 * -lt 小于 * -le 小于等于 * -ge 大于等于 * -z 空串 * = 两个字符相等 * != 两个字符不等 * -n 非空串
这里的-d 参数判断$myPath是否存在
if [ ! -d "$myPath"]; then mkdir "$myPath" fi
这里的-f参数判断$myFile是否存在
if [ ! -f "$myFile" ]; then touch "$myFile" fi
下面是我linux的脚本例子。用于编译嵌入式程序,编译好之后,把程序通过ssh拷贝到开发板:
make CROSS_COMPILE=$crossPath ARCH=arm if [ $? -eq 0 ]; then echo "Make module success!" else echo "----XXX----Make module Failed!!" exit 1; fi arm-phytec-linux-gnueabi-gcc mxc_test.c -o mxc_test.exe if [ $? -eq 0 ]; then echo "Make mxc_test.exe success!" else echo "----XXX----Make mxc_test.exe Failed!!" exit 1; fi if [ ! -n $1 ]; then echo "Please Input y object IP!" else scp /home/xrz/tst2/mxc_sdma_memcopy_test2.ko root@$1:/tmp scp /home/xrz/tst2/mxc_test.exe root@$1:/tmp fi
相关文章推荐
- linux终端 及 tty who echo 命令用法 和 shell bash 变量
- 关于linux bash shell中sort命令指定分隔符的用法
- linux中一些命令的用法及解释
- 在Linux下初学shell命令及例子(1)
- linux chsh命令参数及用法详解(linux设置系统shell命令)
- explainshell:超级强大的Linux命令解释工具
- linux ulimit命令参数及用法详解--linux限定shell启动进程资源
- Linux--Shell 编程-bash,命令替换,if分支嵌套,运算,输入输出
- Linux下Shell编程——sed命令基本用法
- bash shell (4) linux bg fg 命令
- Linux下Shell编程——sed命令基本用法
- [Linux]:Bash shell字符串截取及命令替换
- [Linux] shell read 命令参数 -p用法 [大三TJB_708]
- bash shell (3) linux trap 命令
- Unix/Linux下的Shell命令解释程序
- 【Linux】Bash Shell之date用法
- Linux Shell I/O Redirector Function(命令解释)
- Linux Shell I/O Redirector Function (命令解释)
- linux bash shell 中getopts 命令 和 python 中 getopt 函数的比较总结
- linux ulimit命令参数及用法详解--linux限定shell启动进程资源