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

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
    A+
发布日期:2021年08月03日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: