Originally Posted by Drigo
But I would like just the 'dim4 ' line to appear without the pixdim4 line....like this:
#I want the output just with the first line:
If you just want to search for first line, then there is no need for grep.
$ <command> | head -n1
But if you are referring to return only first hit
, then, any of these will work
$ <command> | grep -w -m1 'dim4'
$ <command> | grep -m1 '\<dim4\>'
$ <command> | grep -m1 '\bdim4\b'