SHELL7 打印字母数小于8的单词
<h2>描述</h2><p>写一个bash脚本以统计一个文本文件nowcoder.txt中字母数小于8的单词。<br />
示例:<br />
假设 nowcoder.txt 内容如下:</p>
<pre><code>how they are implemented and applied in computer
</code></pre>
<p>你的脚本应当输出:</p>
<pre><code>how
they
are
and
applied
in
</code></pre>
<p>说明:<br />
不用担心你输出的空格以及换行的问题</p>
<pre><code>#!/bin/bash
read line < nowcoder.txt
for n in $line
do
if [ "${#n}" -lt 8 ]
then
echo "${n}"
fi
done
</code></pre>
页:
[1]