linux运维经验分享
2017年8月28日
shell习题
No Comments
aming
如题,把一个文本文档中只有一个数字的行给打印出来。
参考答案:
#!/bin/bash f=/etc/passwd line=`wc -l $f|awk '{print $1}'` for l in `seq 1 $line`; do n=`sed -n "$l"p $f|grep -o '[0-9]'|wc -l`; if [ $n -eq 1 ]; then sed -n "$l"p $f fi done
shell习题-打印只有一个数字的行
2017年8月28日
shell习题
No Comments
aming
如题,把一个文本文档中只有一个数字的行给打印出来。
参考答案:
shell习题