shell文件行单词字符操作统计

发布时间:2021-08-03 22:12:40 阅读:1412次

cat /tmp/test/file.txt

hello the world
god is a girl

大家好

pi@bananapi ~/shell $ cat filewhile.sh
#!/bin/bash
while read line;
do echo $line
done < <(find . -type f -print)
#done < <(cat file.txt)
#done < file.txt

test@test:/tmp/test$ cat file.txt | while read LINE do echo $LINE done
test@test:/tmp/test$ while read line; do echo $line; done <file.txt
hello the world
god is a girl
大家好
test@test:/tmp/test$ line="hello the world"
test@test:/tmp/test$ for i in $line; do echo $i; done
hello
the
world
test@test:/tmp/test$ word="hello the world"
test@test:/tmp/test$ echo ${#word}
15
test@test:/tmp/test$ echo ${word:0:6}
hello
test@test:/tmp/test$ for((i=0;i<${#word};i++)); do echo ${word:$i:1}; done
h
e
l
l
o
 
t
h
e
 
w
o
r
l
d

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询
上一篇:diff 用法
下一篇:linux解压

转载请注明:shell文件行单词字符操作统计 出自老鄢博客 | 欢迎分享