SHELL4 输出第5行的内容
<h2>描述</h2><p>编写一个bash脚本以输出一个文本文件nowcoder.txt中第5行的内容。</p>
<p>示例:<br />
假设 nowcoder.txt 内容如下:</p>
<pre><code>welcome
to
nowcoder
this
is
shell
code
</code></pre>
<p>你的脚本应当输出:<br />
is</p>
<pre><code>#!/bin/bash
line=1
while read value
do
if [ $line -eq 5 ]
then echo $value
fi
((line++))
done < nowcoder.txt
</code></pre>
页:
[1]