I have a file that has declarations in it with capital words, something like:public final Foo BAR;these declarations are not all uniform.  Is there a way for me to grep out just the capital lettered words from the line?  I know how to find lines that have capital letters in them, but thats not what I want.  I want only the matching capital lettered word.  Thanks!
grep for capital words
grep
Actually with the -o switch, GNU grep returns only what it has matched. How about:grep -oP \w*[A-Z]+\w* yourfile.txtNote that this regex will match words with capital letters anywhere in them, not necessarily the beginning. You should tune it to meet your needs if they differ.As pointed out below, this might not be the most portable of solutions. A portable alternative in Perl is perl -nE 'say $1  while /(\w*[A-Z]+\w*)/g' yourfile.txt