Unix cut operation Unix cut operation unix unix

Unix cut operation


If you want the literal text "undergrad" in the brackets, this should work:

cut -d "(" -f 2 <text> | cut -d ")" -f 1

or equivalently

echo <text> | cut -d "(" -f 2 | cut -d ")" -f 1


If this string comes from id, then you can just call id -gn instead.


var1=$(cmd |sed 's/.*(\([^)]*\))/\1/')