大佬们看看哪有问题?
#!/bin/bash# File Name: max_len_str_at_pi1-10.sh
# Author: sunowsir
# Mail: [email protected]
# Created Time: 2018年10月14日 星期日 16时47分44秒grep -EIHron '[a-zA-Z]+' './' 2> /dev/null | awk -F ':' '
BEGIN{
first = $0;
second = $0;
third = $0;
first_len = length(first);
second_len = length(second);
third_len = length(third);
}
{
now_str = $0;
now_length = length($3);
if (now_length > first_len) {
third = second;
second = first;
first = now_str;
first_len = now_length;
} else if (now_length > second_len && now_length < first_len) {
third = second;
second = now_str;
second_len = now_length;
} else if (now_length > third_len && now_length < second_len) {
third = now_str;
third_len = now_length;
}
}
END{
printf(" first : \n %s \n second : \n %s \n third : \n %s \n", first, second, third);
}'
#!/bin/bash# File Name: max_len_str_at_pi1-10.sh
# Author: sunowsir
# Mail: [email protected]
# Created Time: 2018年10月14日 星期日 16时47分44秒grep -EIHron '[a-zA-Z]+' './' 2> /dev/null | awk -F ':' '
BEGIN{
first = $0;
second = $0;
third = $0;
first_len = length(first);
second_len = length(second);
third_len = length(third);
}
{
now_str = $0;
now_length = length($3);
if (now_length > first_len) {
third = second;
second = first;
first = now_str;
first_len = now_length;
} else if (now_length > second_len && now_length < first_len) {
third = second;
second = now_str;
second_len = now_length;
} else if (now_length > third_len && now_length < second_len) {
third = now_str;
third_len = now_length;
}
}
END{
printf(" first : \n %s \n second : \n %s \n third : \n %s \n", first, second, third);
}'
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货