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