linux正则表达式 grep egrep用法
shell 命令执行的相应顺序 && 令1 && 命令2 如果这个命令1执行成功& &那么执行这个命2 mv myfile myfile2 && echo "if you are seeing this then mv was success!" || 如果| |左边的命令(命令1)未执行成功,那么就执行| |右边的命令(命令2) mv myfile myfile2 && echo "if you are seeing this then mv was success! " 从一个审计文件中抽取第1个和第2个域,并将其输出到一个临时文件中,如果这一操作未成功,我希望能够收到一个相应邮件: awk '{print$1,$2}' test3 >test2 || echo "sorry the extraction didn't work " | mail root (命令 1; 命令 2;. . . ) 如果使用{ }来代替(),那么相应的命令将在子s h e l l而不是当前s h e l l中作为一个整体被执行,只有在{ }中所有命令的输出作为一个整体被重定向时,其中的命令才被放到子s h e l l中执行,否则在当前s h e l l执行。 例子: 如果s o r t命令执行成功了,可以先将输出文件备份,然后再打印 test.sorted && (cp test.sorted