Bash Script 에서 Script 에 관한 문법


Bash Script 에서 따로 자료형을 입력하지 않아도, initial value 가 string 형태의 경우 string 자료형으로 인식한다.


1. String Length

${#string} : string 의 길이 

expr length $string


2. Substring

${string:position} : string 의 앞에서 부터 position 의 위치 부터 string의 끝까지의 substring (position은 0부터 시작한다.)

${string:position:length} : string 의 앞에서 부터 position 위치 부터 length 길이의 substring


참조

http://tldp.org/LDP/abs/html/string-manipulation.html


'Programming > Bash Script' 카테고리의 다른 글

Bash Script Variable Split by Space  (0) 2018.02.04
Bash Script Echo  (0) 2018.02.04
Bash Script If statement  (0) 2017.07.04
Bash script argument  (0) 2017.06.20
Bash script sudo 권한 체크  (1) 2017.06.19

+ Recent posts