牛客220118974号
牛客220118974号
全部文章
分类
归档
标签
去牛客网
登录
/
注册
牛客220118974号的博客
全部文章
(共18篇)
题解 | 打印只有一个数字的行
#!/bin/bash while read line;do num=$(echo $line | grep -o [0-9] | wc -l) if [ $num -eq 1 ];then echo $line fi done < nowcoder....
2025-11-02
0
16
题解 | 域名进行计数排序处理
#!/bin/bash domains="" while read line;do domain=$(echo $line | cut -d '/' -f 3) domains=${domains}$'\n'${domain} done < nowcode...
2025-11-02
0
18
题解 | 将字段逆序输出文件的每行
#!/bin/bash while read line;do line=$(echo "$line" | sed 's/:/\n/g') newline="" l=$(echo "$line" | wc -l) ...
2025-11-01
0
20
题解 | 判断输入的是否为IP地址
#!/bin/bash while read line;do dot=$(echo $line | grep -o '\.' | wc -l) #.会被转义,需要使用\. if [ ! $dot -eq 3 ];then echo 'error' c...
2025-11-01
0
19
题解 | 去掉不需要的单词
#!/bin/bash while read line;do isBb=$(echo $line | grep [bB] | wc -l) if [ $isBb -eq 0 ];then echo "$line" fi done
2025-11-01
0
13
题解 | 求平均值
#!/bin/bash read l sum=0 for (( i=1;i<=$l;i=i+1 ));do read a sum=$(($sum+$a)) done avg=$(echo "scale=3;$sum/$l" | bc) echo $avg
2025-11-01
0
12
题解 | 去掉所有包含this的句子
#!/bin/bash while read line;do isThis=$(echo "$line" | grep this | wc -l) if [ $isThis -eq 0 ];then echo "$line" ...
2025-11-01
0
16
题解 | 打印每一行出现的数字个数
#!/bin/bash sum=0 ii=0 while read line;do ii=$(($ii+1)) num=$(echo "$line" | grep -o [1-5] | wc -l) echo "line${ii} number...
2025-11-01
0
17
首页
上一页
1
2
下一页
末页