好好爱自己!

bash shell redirecting code block

参考了:https://www.cnblogs.com/sparkdev/p/10247187.html

https://www.tldp.org/LDP/abs/html/redircb.html

 

awk 用法(使用入门)

 

awk 用法:awk ' pattern {action} '  

 

----------------------------------------------

 

 #!/bin/bash
 
 E_WRONG_ARGS=71
 if [ -z "$1" ]
 then
     echo "Usage: $0 input-file output-file"
     exit $E_WRONG_ARGS
 fi
 
 if [ -z "$2" ]
 then
     echo "Usage: $0 input-file output-file"
     exit $E_WRONG_ARGS
 fi
 
 FinalName="xxyy"
 line_count=$(wc "$1" | awk '{ print $1 }')
 
 for name in $(seq $line_count)
 do
     read name
     echo "$name"
     if [ "$name" = "$FinalName" ]
     then
         break
     fi
 done  < $1 > $2
 exit 0
                                                                            

  

 

posted @ 2019-01-10 15:24  立志做一个好的程序员  阅读(331)  评论(0)    收藏  举报

不断学习创作,与自己快乐相处