2015-02-10 79 views
0

如何使用awk命令在ksh文件中打印.log文件? 腳本去是這樣的:如何使用awk命令在ksh文件中打印文件

##create file here 
## Start process 
awk 'BEGIN { 
     some code here 
    } 
    { 

##Logic here 
##Print to file 

    } 
    END {} 
' $OUTPUTNEEDEDTOBEPRINTED 
+1

只是重新定位你的'print's :'print ...>「my.log」'。 – fedorqui 2015-02-10 11:29:12

回答

2

您可以awk代碼中重定向:

##create file here 
## Start process 
awk 'BEGIN { 
     some code here 
    } 
    { 
    print > "myfile" 


    } 
    END {} 
' "$OUTPUTNEEDEDTOBEPRINTED" 

或者只是重新定位你的輸出awk

##create file here 
## Start process 
awk 'BEGIN { 
     some code here 
    } 
    { 

##Logic here 
##Print to file 

    } 
    END {} 
' "$OUTPUTNEEDEDTOBEPRINTED" > "myfile"