bash shell redirecting code block

时间:2021-08-12 02:11:49

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

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

awk 用法(使用入门)

 

awk 用法:awk ' pattern {action} '

bash shell redirecting code block

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

bash shell redirecting code block

 #!/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