把一个文本文档中只有一个数字的行给打印出来

 题目要求
用shell实现,把一个文本文档中只有一个数字的行给打印出来。

 参考答案

#!/bin/bash
while read line
do
    n=`echo $line |sed 's/[^0-9]//g'|wc -L`
    if [ $n -eq 1 ]
    then
    echo $line
    fi
done < 1.txt

 

posted @ 2021-02-26 12:29  星火撩原  阅读(76)  评论(0)    收藏  举报