Solved

find print only uppercase words from a file

Posted on 2007-04-06
3
370 Views
Last Modified: 2008-01-09
I need a script  that will extract from a file only those words in uppercase, and print only the uppercase words
example: print only those words from a Makefile that are all in uppercase
reason for script: uppercase words are typically macros in a Makefile. I wrote a one liner that will expand the macro, but am having difficulty just extracting the macros from the Makefile.

I will be using this in a Linux/Unix environment

Thanks.
0
Comment
Question by:laughtrax4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Assisted Solution

by:DocGyver
DocGyver earned 166 total points
ID: 18866585
well the following egrep will get all lines that have "words" of at least 2 all uppercase characters

egrep  '\W[A-Z]{2,}\W|^[A-Z]{2,}\W|\W[A-Z]{2,}$'

once you have that it should be a fairly simple 'sed' command to give you only the matching part.  Can you handle the sed?

Doc..
0
 
LVL 15

Accepted Solution

by:
veedar earned 168 total points
ID: 18869454
This deletes all lower case, punctuation and digits....leaving just uppercase...

cat file | tr -d [:lower:][:punct:][:digit:]

0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 166 total points
ID: 18879221
grep -o -w '[A-Z]*' /some/file
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question