- 论坛徽章:
- 4
|
本帖最后由 杰瑞26 于 2016-08-11 09:10 编辑
- #!/bin/bash
- # filename: test.sh
- sentence="When you're attracted to someone it just means that your subconscious is attracted to their subconscious, subconsciously.
- So what we think of as fate, is just two neuroses knowing they're a perfect match."
- for word in ${sentence}
- do
- new=`echo $word | tr -cd '[a-zA-Z]'` # 去除句子中的 ,或者'
- len=${#new} # 求长度
- if [ "$len" -ge 5 ] # 再判断
- then
- echo $new
- fi
- done
复制代码 结果输出:- root@localhost:~/training# ./test.sh
- youre
- attracted
- someone
- means
- subconscious
- attracted
- their
- subconscious
- subconsciously
- think
- neuroses
- knowing
- theyre
- perfect
- match
复制代码 |
|