#!/bin/bash #空格分割,数组存单词,统计单词长度判断后输出单词 IFS=" " words=($(cat nowcoder.txt)) for word in ${words[@]} do [ ${#word} -lt 8 ] && echo $word done < nowcoder.txt exit 0