O Bash pode corresponder expressões regulares ao operador =~
em [[ ... ]]
:
#! /bin/bash
line='attempting to create a 512^3 level (with Dirichlet BC) using a 16^3 grid of 32^3 boxes and 800 tasks...'
num='([0-9^]+)'
nonum='[^0-9^]+'
if [[ $line =~ $num$nonum$num$nonum$num$nonum$num ]] ; then
level=${BASH_REMATCH[1]}
grid=${BASH_REMATCH[2]}
boxes=${BASH_REMATCH[3]}
tasks=${BASH_REMATCH[4]}
echo "Level $level, grid $grid, boxes $boxes, tasks $tasks."
fi