示例:
假设 nowcoder.txt 内容如下:
how they are implemented and applied in computer
how
they
are
and
applied
in说明:
不用担心你输出的空格以及换行的问题
how they are implemented and applied in computer
how they are and applied in
for i in `awk '{print}' nowcoder.txt`
do
if [ ${#i} -lt 8 ]
then
echo $i
fi
done awk 'BEGIN{RS="[[:space:]]+"}length($0)<8{print $0}' nowcoder.txt for i in `cat nowcoder.txt`;do if [ $(echo $i | wc -m) -lt 9 ] ;then echo $i;fi;done #换行符占一个
for i in `cat nowcoder.txt`;do if (($(echo $i | wc -L)<8)) ;then echo $i;fi;done
for i in `cat nowcoder.txt`;do if (($(expr length $i)<8));then echo $i;fi;done
for i in `cat nowcoder.txt`;do if((${#i}<8));then echo $i;fi;done
awk '{for(i=1;i<=NF;i++) if(length($i)<8) print $i }' nowcoder.txt
xargs -n1 -a nowcoder.txt | while read p; do if (($(echo $p | wc -L)<8)); then echo $p; fi; done