Solved

find print only uppercase words from a file

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can't get /etc/resolv.conf to configure after reboot 8 71
gdb doesn't stop on breakpoint 2 48
Virtualizing very old guest OS 4 79
aix unix tar error 3 40
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
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.:

914 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

17 Experts available now in Live!

Get 1:1 Help Now