Created
March 26, 2019 16:18
-
-
Save PoplarYang/1f21649c22a014c87ca3d6b742e046c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 行迭代 | |
# while 循环法 | |
while read line;do | |
echo $line; | |
done < file.txt | |
# 命令行法 | |
cat file.txt | (while read line;do echo $line;done) | |
# awk法 | |
cat file.txt | awk '{print}' | |
# 单词迭代 | |
for word in $line; do echo $word; done | |
# 字符迭代 | |
# ${string:start_pos:num_of_chars}:从字符串中提取一个字符;(bash文本切片) | |
# ${#word}:返回变量word的长度 | |
for((i=0;i<${#word};i++)) | |
do | |
echo ${word:i:1); | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment