以下是我在linux下執行的dd_kill.dat的內容:
*********************我是分隔線************************
#!/usr/bin/awk -f
BEGIN {
system ("ps -aux | grep ${USER} | grep dd > ${HOME}/dd_kill.log")
Log_file = ENVIRON["HOME"]"/dd_kill.log"
print Log_file
while ( getline < Log_file > 0 ) {
if($ll ~ dd) {
print "kill -9 "$2 " " $ll
system("kill -9 " $2)
}
}
system("rm ${HOME}/dd_kill.log")
}
*********************我是分隔線************************
目的是要kill掉名稱裡包含有"dd"的所有程序
但是當我在UNIX系統下執行時
我有稍作修改(aux->ef):
*********************我是分隔線************************
#!/usr/bin/awk -f
BEGIN {
system ("ps -ef | grep ${USER} | grep dd > ${HOME}/dd_kill.log")
Log_file = ENVIRON["HOME"]"/dd_kill.log"
print Log_file
while ( getline < Log_file > 0 ) {
if($ll ~ dd) {
print "kill -9 "$2 " " $ll
system("kill -9 " $2)
}
}
system("rm ${HOME}/dd_kill.log")
}
*********************我是分隔線************************
結果執行 ./dd_kill.dat的結果如下:
awk: syntax error near line 8
awk: illegal statement near line 8
awk: syntax error near line 9
awk: illegal statement near line 9
awk: syntax error near line 15
awk: illegal statement near line 15
感覺像是UNIX的語法不支援
請問一下要怎麼修改我的程式呢?
更新1:
Dear 可魯: 我在while那一行就出錯了耶 而且我把if($ll ~ dd) 改成if($ll ~ "dd") 這一行的錯誤也還是依然存在耶