Sponsored Content
Top Forums Shell Programming and Scripting Get group of consecutive uppercase words using gawk Post 302644781 by neutronscott on Tuesday 22nd of May 2012 12:07:03 PM
Old 05-22-2012
Quote:
Originally Posted by louisJ
I get the first uppercase word after "The Thing" but I don't know how to get the others.

Thanks
You need to group your "word" definition, and allow it to repeat. ( regex )*. I changed it to match spaces at the beginning instead of the end to simplify phrases that may be at the end of line..

Code:
awk 'match($0,/The Thing([[:space:]]*[[:upper:]][^[:space:]]*)*/) { print substr($0,RSTART,RLENGTH) }' input
The Thing I Only
The Thing That Are Like Men's Eyewear

This User Gave Thanks to neutronscott For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing uppercase words from textfiles

I have the task of removing all uppercase words from csv files, mit 10000's lines. I think it shoud be possible with regex's, something like "s/{2,}//g" but I can't get it work with sed or Vi. It would also be possible to script in ksh, awk, perl or python. example this "this is a EXAMPLE... (5 Replies)
Discussion started by: frieling
5 Replies

2. Shell Programming and Scripting

Shell script to find out words, replace them and count words

hello, i 'd like your help about a bash script which: 1. finds inside the html file (it is attached with my post) the code number of the Latest Stable Kernel, 2.finds the link which leads to the download location of the Latest Stable Kernel version, (the right link should lead to the file... (3 Replies)
Discussion started by: alex83
3 Replies

3. Shell Programming and Scripting

finding and removing 2 identical consecutive words in a text

i want to write a shell script that correct a text file.for example if i have the input file: "john has has 2 apples anne has 3 oranges oranges" i want that the output file be like this: "john has 2 apples anne has 3 oranges" i've tried to read line by line from input text file into array... (11 Replies)
Discussion started by: cocostaec
11 Replies

4. Shell Programming and Scripting

Finding consecutive same words in a file

Hi All, I tried this but I am having trouble formulating this: I have a file that looks like this (this is a sample file words can be different): network router frame network router computer card host computer card One can see that in this file "network" and "router" occur... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

5. Shell Programming and Scripting

matching group of words

Hi, I am stuck with a problem, will be thankful for your guidance and help. I have two files. Each line is a group of words with first word as group Id. eg. 'gp1' in File1 and 'grp1' in File2. <File1> gp1 : xyz xys3 syt2 ssx itt kty gp2 : syt2 kgk iti op2 gp3 : ppy yt5 itt sky... (11 Replies)
Discussion started by: mira
11 Replies

6. Shell Programming and Scripting

How to move a group of words before another group of words

Hi I have a file containing lines with several consecutive words starting with a capital letter (i.e. Zuvaia Flex), followed by "de The New Foul", and I would like to put "The New Foul" before the group with capital letters and delete "de" From the line: Le short femme Zuvaia Flex de The... (2 Replies)
Discussion started by: louisJ
2 Replies

7. Shell Programming and Scripting

Match groups of capital words using gawk

Hi I'd like to extract from a text file, using gawk, the groups of words beginning with a capital letter, that are not at the begining of a sentence (i.e. Not after a full stop and a pace ". "), including special characters like registered or trademark (® or ™ ). For example I would like to... (1 Reply)
Discussion started by: louisJ
1 Replies

8. Shell Programming and Scripting

Gawk gensub, match capital words and lowercase words

Hi I have strings like these : Vengeance mitt Men Vengeance gloves Women Quatro Windstopper Etip gloves Quatro Windstopper Etip gloves Girls Thermobite hooded jacket Thermobite Triclimate snow jacket Boys Thermobite Triclimate snow jacket and I would like to get the lower case words at... (2 Replies)
Discussion started by: louisJ
2 Replies

9. Shell Programming and Scripting

Search words in any quote position and then change the words

hi, i need to replace all words in any quote position and then need to change the words inside the file thousand of raw. textfile data : "Ninguno","Confirma","JuicioABC" "JuicioCOMP","Recurso","JuicioABC" "JuicioDELL","Nulidad","Nosino" "Solidade","JuicioEUR","Segundo" need... (1 Reply)
Discussion started by: benjietambling
1 Replies

10. Shell Programming and Scripting

Replace particular words in file based on if finds another words in that line

Hi All, I need one help to replace particular words in file based on if finds another words in that file . i.e. my self is peter@king. i am staying at north sydney. we all are peter@king. How to replace peter to sham if it finds @king in any line of that file. Please help me... (8 Replies)
Discussion started by: Rajib Podder
8 Replies
Test::ClassAPI(3pm)					User Contributed Perl Documentation				       Test::ClassAPI(3pm)

NAME
Test::ClassAPI - Provides basic first-pass API testing for large class trees DESCRIPTION
For many APIs with large numbers of classes, it can be very useful to be able to do a quick once-over to make sure that classes, methods, and inheritance is correct, before doing more comprehensive testing. This module aims to provide such a capability. Using Test::ClassAPI Test::ClassAPI is used with a fairly standard looking test script, with the API description contained in a __DATA__ section at the end of the script. #!/usr/bin/perl # Test the API for Foo::Bar use strict; use Test::More 'tests' => 123; # Optional use Test::ClassAPI; # Load the API to test use Foo::Bar; # Execute the tests Test::ClassAPI->execute; __DATA__ Foo::Bar::Thing=interface Foo::Bar::Object=abstract Foo::Bar::Planet=class [Foo::Bar::Thing] foo=method [Foo::Bar::Object] bar=method whatsit=method [Foo::Bar::Planet] Foo::Bar::Object=isa Foo::Bar::Thing=isa blow_up=method freeze=method thaw=method Looking at the test script, the code itself is fairly simple. We first load Test::More and Test::ClassAPI. The loading and specification of a test plan is optional, Test::ClassAPI will provide a plan automatically if needed. This is followed by a compulsory __DATA__ section, containing the API description. This description is in provided in the general form of a Windows style .ini file and is structured as follows. Class Manifest At the beginning of the file, in the root section of the config file, is a list of entries where the key represents a class name, and the value is one of either 'class', 'abstract', or 'interface'. The 'class' entry indicates a fully fledged class. That is, the class is tested to ensure it has been loaded, and the existance of every method listed in the section ( and its superclasses ) is tested for. The 'abstract' entry indicates an abstract class, one which is part of our class tree, and needs to exist, but is never instantiated directly, and thus does not have to itself implement all of the methods listed for it. Generally, many individual 'class' entries will inherit from an 'abstract', and thus a method listed in the abstract's section will be tested for in all the subclasses of it. The 'interface' entry indicates an external interface that is not part of our class tree, but is inherited from by one or more of our classes, and thus the methods listed in the interface's section are tested for in all the classes that inherit from it. For example, if a class inherits from, and implements, the File::Handle interface, a "File::Handle=interface" entry could be added, with the "[File::Handle]" section listing all the methods in File::Handle that our class tree actually cares about. No tests, for class or method existance, are done on the interface itself. Class Sections Every class listed in the class manifest MUST have an individual section, indicated by "[Class::Name]" and containing a set of entries where the key is the name of something to test, and the value is the type of test for it. The 'isa' test checks inheritance, to make sure that the class the section is for is (by some path) a sub-class of something else. This does not have to be an immediate sub-class. Any class refered to (recursively) in a 'isa' test will have its 'method' test entries applied to the class as well. The 'method' test is a simple method existance test, using "UNIVERSAL::can" to make sure that the method exists in the class. METHODS
execute The "Test::ClassAPI" has a single method, "execute" which is used to start the testing process. It accepts a single option argument, 'complete', which indicates to the testing process that the API listed should be considered a complete list of the entire API. This enables an additional test for each class to ensure that every public method in the class is detailed in the API description, and that nothing has been "missed". SUPPORT
Bugs should be submitted via the CPAN bug tracker, located at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-ClassAPI <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-ClassAPI> For other issues, or commercial enhancement or support, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2002 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.14.2 2009-07-13 Test::ClassAPI(3pm)
All times are GMT -4. The time now is 02:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy