Using Extension Parameters :
str='test1@test2'
echo "${str#*@}"
- The symbol
#says: Remove the smallest extension prefix matching the pattern. - The symbol
%means the removal of the smallest suffix of the extension corresponding to the pattern. (So you can do "${str%@*}"to get the part "test1".) - The symbol
/deletes the smallest and first expansion substring corresponding to the following pattern. Bash has it, but it is not POSIX.
, .