Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dyxlesic help , script to extract any case words 3

Status
Not open for further replies.

tjbradford

Technical User
Dec 14, 2007
229
GB
Hi all, I'm looking for an app that can go through a text file and extract all the caps words from the content i.e. DHCP CCNA etc then place them into a new file each line with a single word. is this possible , i posted here first as i think Linux might be the quickest way to do this.

any ideas ?
 
tr -cs '[:alpha:]' '[\n*]' </path/to/input | grep -E '^[A-Z]+$' >newfile

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
either of the commands seem to run but never end and never output anything on the screen or into the file , what could be wrong?
 
what could be wrong
Without seeing YOUR code, it's hard to say anything ...
Which flavor of *nix ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
it puppy linux , I only have a full Linux OS at work , puppy has done me well in the past though

if I use the following as a sample file

ASE
XCCVFF
fdfghfhj hjghfhjg FSFF juhiou CXCX
idfgfgfdgdfg:
jhghjgVBFRB

saved as file.txt

i have tried both the above commands

tr -cs '[:alpha:]' '[\n*]' </file | grep -E '^[A-Z]+$' >file2.txt

&

tr -cs '[:alpha:]' '\n' /file | grep '^[A-Z]*$'

tr seems to be running or atleast attempting to but thats it , I tried cat with the grep statement which gave me the lines containing upper case it i add -o then it shows everything i want but a letter per line.

 
Sorry, I know nothing about 'puppy linux'.
check the man pages for the tr and grep commands.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for your help i have just tried this on my Ubuntu OS and it worked a treat , thanks for your help.


Cheers people's
 
Hi

While Puppy Linux is a Live CD distribution, is possible that your [tt]tr[/tt] and/or [tt]grep[/tt] is not real, just a BusyBox or similar emulation.

By the way, your -o idea is brilliant. [medal]
Code:
grep -oE '\b([[:upper:]]+)\b' /input/file

Feherke.
 
Nice! With slightly less punctuation:

Code:
grep -woE '[[:upper:]]+' /input/file

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top