如何使用 Bash 检索变量的前 10 个字符?
FOO="qwertzuiopasdfghjklyxcvbnm"
我需要得到
qwertzuiop
如果变量是:
然后
echo ${FOO:0:10}
将给出前 10 个字符。
使用
head
echo $FOO | head -c 10 => qwertzuiop