How do I split a string on a delimiter in Bash?

I have this string stored in a variable: IN=”[email protected];[email protected]” Now I would like to split the strings by ; delimiter so that I have: ADDR1=”[email protected]” ADDR2=”[email protected]” I don’t necessarily need the ADDR1 and ADDR2 variables. If they are elements of an array that’s even better. After suggestions from the answers below, I ended up with … Read more

Meaning of $? (dollar question mark) in shell scripts

This is the exit status of the last executed command. For example the command true always returns a status of 0 and false always returns a status of 1: true echo $? # echoes 0 false echo $? # echoes 1 From the manual: (acessible by calling man bash in your shell) $?       Expands to the exit status of the most recently executed foreground … Read more

Python script header

First, any time you run a script using the interpreter explicitly, as in $ python ./my_script.py $ ksh ~/bin/redouble.sh $ lua5.1 /usr/local/bin/osbf3 the #! line is always ignored. The #! line is a Unix feature of executable scripts only, and you can see it documented in full on the man page for execve(2). There you will find that the word following #! must be the … Read more