Solved

find print only uppercase words from a file

Posted on 2007-04-06
3
368 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

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 …
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

759 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