2020-10-27 shell note1

echo 转义字符输出

$ echo "a\tb\tc"
a\tb\tc
$ echo -e "a\tb\tc"
a b c

tr 用法

$ echo -e "a\tb\tc" | tr "\t" "-"
a-b-c

tr 删除 和 替换

$ echo '["a","b","c","d"]'
["a","b","c","d"]
$ echo '["a","b","c","d"]' | tr -d ']"[' | tr "," "\n"
a
b
c
d

printf vs echo 格式化输出

$ for i in $(seq 4); do printf '%s\n' $i;done
1
2
3
4

你可能感兴趣的:(2020-10-27 shell note1)