LoginSignup
5
5

More than 5 years have passed since last update.

bash > 文字列変数の一部を表示 > echo ${name:0:2}

Last updated at Posted at 2015-03-19

動作確認

CentOS 6.5

文字列変数の一部の文字を取得したい時、以下のようにする

substring-exec
#!/bin/env bash

name=ABCDEFG

echo ${name:0:2}  # AB
echo ${name:2:2}  # CD

これを使ったendian変換例がSOにあった。

5
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5