2015-02-10 80 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"