sed only keep string between brackets code example Example: sed only keep string between brackets echo $str | cut -d "[" -f2 | cut -d "]" -f1