LeetCode 195. Tenth Line (shell)

来源:互联网 发布:小米手机数据迁移应用 编辑:程序博客网 时间:2024/06/06 01:49

描述

打印文件的第十行内容

解决

迭代


# Read from the file file.txt and output the tenth line to stdoutcount=1cat file.txt | while read linedo    if [ $count -eq 10 ]    then        echo "$line"        break    else        count=$[ $count + 1 ]    fidone 
0 0
原创粉丝点击