Skip to content

Instantly share code, notes, and snippets.

@GithubMrxia
Created May 15, 2020 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GithubMrxia/73470f82a3ddd4f6a38e46d44818bbf7 to your computer and use it in GitHub Desktop.
Save GithubMrxia/73470f82a3ddd4f6a38e46d44818bbf7 to your computer and use it in GitHub Desktop.
unix 脚本
#!/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