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
写一个 bash脚本以输出一个文本文件 nowcoder.txt 中第5行的内容。
示例:
假设 nowcoder.txt 内容如下:
welcome
to
nowcoder
this
is
shell
code
你的脚本应当输出:
is
awk 'NR==5{print $0}'
sed -n '5p' nowcoder.txt