参考了:
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