1 #!/bin/bash 2 # self-destruct.sh 3 4 kill $$ # Script kills its own process here. 5 # Recall that "$$" is the script's PID. 6 7 echo "This line will not echo." 8 # Instead, the shell sends a "Terminated" message to stdout. 9 10 exit 0 11 12 # After this script terminates prematurely, 13 #+ what exit status does it return? 14 # 15 # sh self-destruct.sh 16 # echo $? 17 # 143 18 # 19 # 143 = 128 + 15 20 # TERM signal |
原帖由 寂寞烈火 于 2007-8-28 15:03 发表
awk的sub
awk '{sub(/.*/,"",$1);sub(/^ /,"");print}'
如果文件行数成百上千行的话, 你的cut就不成啦
原帖由 ivhb 于 2007-8-28 15:23 发表
awk下,是否可以
awk -F "^[ ]*[0-9]+[ ]+" '{print (NF == 2) ? $2 : $0}' ur-file
写的晦涩一点,但是更加简洁就是
awk -F "^[ ]*[0-9]+[ ]+" '{print $(1+(NF==2))}'
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |