Solved

find print only uppercase words from a file

Posted on 2007-04-06
3
362 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
3 Comments
 
LVL 6

Assisted Solution

by:DocGyver
DocGyver earned 166 total points
Comment Utility
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
Comment Utility
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
Comment Utility
grep -o -w '[A-Z]*' /some/file
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now