Solved

find print only uppercase words from a file

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

830 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