공부
[Sh] split string
승가비
2020. 4. 16. 00:44
728x90
str="abc@naver.com;bcd@naver.com;cde@naver.com"
mails=$(echo $str | tr ";" "\n")
for mail in $mails
do
echo "[$mail]"
done
리눅스 쉘 스크립트 문자열 분리(string split) 명령어 구현
- 출처split 명령어는 구분자(delimiter)를 기준으로 문자열을 분리하는 명령어입니다. 쉘 스크립트에서는 ...
blog.naver.com
t="one,two,three"
a=($(echo $t | tr ',' "\n"))
https://stackoverflow.com/questions/10586153/how-to-split-a-string-into-an-array-in-bash
How to split a string into an array in Bash?
In a Bash script, I would like to split a line into pieces and store them in an array. For example, given the line: Paris, France, Europe I would like to have the resulting array to look like so: ...
stackoverflow.com
728x90