Skip to content

Instantly share code, notes, and snippets.

@fseasy
Created September 1, 2017 11:44
Show Gist options
  • Save fseasy/f5a26d300f5da864c887afc2b2ea3136 to your computer and use it in GitHub Desktop.
Save fseasy/f5a26d300f5da864c887afc2b2ea3136 to your computer and use it in GitHub Desktop.
判断各个文件行数是否一致!!! 非常重要,因为这个问题接连出了两个BUG!!
!/bin/sh
function is_line_num_equal()
{
if [ $# -eq 0 ];then
return 0
fi
line_cnt="`wc -l $1 | awk -F" " '{print $1}'`"
shift
while [ $# -ne 0 ]; do
cur_line_cnt="`wc -l $1 | awk -F" " '{print $1}'`"
if [ $line_cnt -ne $cur_line_cnt ];then
echo "[$1]"" has different line nums" >/dev/stderr
return 1
fi
shift
done
return 0
}
is_line_num_equal test.sh test.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment