码迷,mamicode.com
首页 > 系统相关 > 详细

shell命令

时间:2020-04-17 23:42:11      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:str   ext   字符串   deb   ima   tmp   case   pyw   comm   

 

What does `set -x` do?

 Take a look: 

help set
help -m set | less

 

set -x enables a mode of the shell where all executed commands are printed to the terminal. In your case it‘s clearly used for debugging, which is a typical use case for set -x: printing every command as it is executed may help you to visualize the control flow of the script if it is not functioning as expected.

set +x disables it.

https://stackoverflow.com/questions/36273665/what-does-set-x-do

 

What does set -e mean in a bash script?

 

 

 https://stackoverflow.com/questions/19622198/what-does-set-e-mean-in-a-bash-script


-e  Exit immediately if a command exits with a non-zero status.







文件比较运算符
-e filename 如果 filename存在,则为真 [ -e /var/log/syslog ]
-d filename 如果 filename为目录,则为真 [ -d /tmp/mydir ]
-f filename 如果 filename为常规文件,则为真 [ -f /usr/bin/grep ]
-L filename 如果 filename为符号链接,则为真 [ -L /usr/bin/grep ]
-r filename 如果 filename可读,则为真 [ -r /var/log/syslog ]
-w filename 如果 filename可写,则为真 [ -w /var/mytmp.txt ]
-x filename 如果 filename可执行,则为真 [ -L /usr/bin/grep ]
filename1-nt filename2 如果 filename1比 filename2新,则为真 [ /tmp/install/etc/services -nt /etc/services ]
filename1-ot filename2 如果 filename1比 filename2旧,则为真 [ /boot/bzImage -ot arch/i386/boot/bzImage ]
字符串比较运算符 (请注意引号的使用,这是防止空格扰乱代码的好方法)
-z string 如果 string长度为零,则为真 [ -z "$myvar" ]
-n string 如果 string长度非零,则为真 [ -n "$myvar" ]
string1= string2 如果 string1与 string2相同,则为真 [ "$myvar" = "one two three" ]
string1!= string2 如果 string1与 string2不同,则为真 [ "$myvar" != "one two three" ]
算术比较运算符
num1-eq num2 等于 [ 3 -eq $mynum ]
num1-ne num2 不等于 [ 3 -ne $mynum ]
num1-lt num2 小于 [ 3 -lt $mynum ]
num1-le num2 小于或等于 [ 3 -le $mynum ]
num1-gt num2 大于 [ 3 -gt $mynum ]
num1-ge num2 大于或等于 [ 3 -ge $mynum ]

shell命令

标签:str   ext   字符串   deb   ima   tmp   case   pyw   comm   

原文地址:https://www.cnblogs.com/sinferwu/p/12723189.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!