生信喵 发表于 2024-12-12 20:40:01

SHELL1 统计文件的行数

<h2>描述</h2>
<p>编写一个shell脚本以输出一个文本文件nowcoder.txt中的行数<br />
示例:<br />
假设 nowcoder.txt 内容如下:</p>
<pre><code>#include &lt;iostream&gt;
using namespace std;
int main()
{
    int a = 10;
    int b = 100;
    cout &lt;&lt; &quot;a + b:&quot; &lt;&lt; a + b &lt;&lt; endl;
    return 0;
}
</code></pre>
<p>你的脚本应当输出:<br />
9</p>

生信喵 发表于 2024-12-12 20:40:57

<pre><code>sed -n '$=' nowcoder.txt
</code></pre>
页: [1]
查看完整版本: SHELL1 统计文件的行数