Created
May 15, 2020 03:06
-
-
Save GithubMrxia/73470f82a3ddd4f6a38e46d44818bbf7 to your computer and use it in GitHub Desktop.
unix 脚本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 分个字符串 | |
function splitStr() | |
{ | |
OLD_IFS=${IFS} | |
IFS=$2, | |
arr=($1) | |
IFS=${OLD_IFS} | |
} | |
string="hello,shell,split,test" | |
splitStr ${string} ',' | |
for str in ${arr[@]} | |
do | |
echo ${str} | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment