Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 Bash 检索变量的前 10 个字符?
FOO="qwertzuiopasdfghjklyxcvbnm"
我需要得到qwertzuiop.
qwertzuiop
如果变量是:FOO="qwertzuiopasdfghjklyxcvbnm"
然后
echo ${FOO:0:10}
将给出前 10 个字符。
使用head命令。
head
echo $FOO | head -c 10 => qwertzuiop