Last active
February 26, 2019 07:44
-
-
Save loloicci/f54640c072ecbb059738f4c78f9a66bf to your computer and use it in GitHub Desktop.
an example to use commas as delimiters for 'for' in bash.
This file contains 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 | |
CMD_LINE="ro root=/dev/example1,/dev/example2 splash quiet" | |
for CMD_PARAM in ${CMD_LINE}; do | |
case ${CMD_PARAM} in | |
root=*) | |
ROOT_DEV=${CMD_PARAM#root=} | |
;; | |
*) | |
echo "parameters other than 'root': ${CMD_PARAM}" | |
;; | |
esac | |
done | |
echo "==== ROOT_DEV ====" | |
echo ${ROOT_DEV} | |
echo "==== DEVICES ====" | |
################ TECH HERE ################ | |
# replace comma with space to split | |
for DEV in ${ROOT_DEV//,/ }; do | |
echo ${DEV} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment