Shell 输出第五行的内容

Shell 输出第五行的内容

题目

写一个 bash脚本以输出一个文本文件 nowcoder.txt 中第5行的内容。

示例:
假设 nowcoder.txt 内容如下:
welcome
to
nowcoder
this
is
shell
code

你的脚本应当输出:
is

题解-awk

awk 'NR==5{print $0}'

题解-sed

sed -n '5p' nowcoder.txt
posted @ 2021-12-06 16:05  rananie  阅读(253)  评论(0编辑  收藏  举报