Sponsored Content
Top Forums Shell Programming and Scripting Gawk gensub, match capital words and lowercase words Post 302901149 by louisJ on Monday 12th of May 2014 10:36:43 AM
Old 05-12-2014
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 the end of each line and put them at the begining and put Men, women, girls, boys, if present, at the end. My attempd doesn't work :

Code:
{ 
      $0=gensub(/^(Men |Women |Boys |Girls |)(([A-Z][a-z\-]+ )+)(([a-z\-]+ )+)/,"\\3\\2\\1","g");
     print $0; 
}

Can you help figure it out with gawk and gensub ?

Thanks

Last edited by louisJ; 05-12-2014 at 12:01 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to find capital letter names in a file without finding words at start of sentence

Hi, I want to be able to list all the names in a file which begin with a capital letter, but I don't want it to list words that begin a new sentence. Is there any way round this? Thanks for your help. (1 Reply)
Discussion started by: kev269
1 Replies

2. Shell Programming and Scripting

search for words with capital leters

Hi, I just want to search a file for any words containng a capital letter and then display these words only as a list I have been trying grep but to no has not helped.(im using the bash shell) (7 Replies)
Discussion started by: djdaniel3
7 Replies

3. Shell Programming and Scripting

gawk and gensub

Hi, $ echo "Hellooo" | gawk '{print gensub(/o{3}/, "z", 1)}' doesn't return "Hellz" as expected while: $ echo "Hellooo" | awk '{print gensub(/o+/, "z", 1)}' produces "Hellz" correctly. Are the {m,n} quantifiers not supported in gensub? I know that sub or gsub could do the job. It's just an... (2 Replies)
Discussion started by: ripat
2 Replies

4. 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

5. 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

6. Shell Programming and Scripting

Get group of consecutive uppercase words using gawk

Hi I'd like to extract, from a text file, the strings starting with "The Thing" and only composed of words with a capital first letter and apostrophes, like for example: "The Thing I Only" from "those are the The Thing I Only go for whatever." or "The Thing That Are Like Men's Eyewear" ... (7 Replies)
Discussion started by: louisJ
7 Replies

7. Shell Programming and Scripting

Make all words begin with capital letter?

I need to use bash to convert sentences where all words start with a small letter into one where all words start with a capital letter. So that a string like: are utilities ready for hurricane sandy becomes: Are Utilities Ready For Hurricane Sandy (10 Replies)
Discussion started by: locoroco
10 Replies

8. Shell Programming and Scripting

Counting all words that start with a capital letter in a string using python dictionary

Hi, I have written the following python snippet to store the capital letter starting words into a dictionary as key and no of its appearances as a value in this dictionary against the key. #!/usr/bin/env python import sys import re hash = {} # initialize an empty dictinonary for line in... (1 Reply)
Discussion started by: royalibrahim
1 Replies

9. 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
IO::Async::Channel(3pm) 				User Contributed Perl Documentation				   IO::Async::Channel(3pm)

NAME
"IO::Async::Channel" - pass values into or out from an IO::Async::Routine DESCRIPTION
A "IO::Async::Channel" object allows Perl values to be passed into or out of an IO::Async::Routine. It is intended to be used primarily with a Routine object rather than independently. For more detail and examples on how to use this object see also the documentation for IO::Async::Routine. A Channel object is shared between the main process of the program and the process running within the Routine. In the main process it will be used in asynchronous mode, and in the Routine process it will be used in synchronous mode. In asynchronous mode all methods return immediately and use "IO::Async"-style callback functions. In synchronous within the Routine process the methods block until they are ready and may be used for flow-control within the routine. Alternatively, a Channel may be shared between two different Routine objects, and not used directly by the controlling program. The channel itself represents a FIFO of Perl reference values. New values may be put into the channel by the "send" method in either mode. Values may be retrieved from it by the "recv" method. Values inserted into the Channel are snapshot by the "send" method. Any changes to referred variables will not be observed by the other end of the Channel after the "send" method returns. Since the channel uses Storable to serialise values to write over the communication filehandle only reference values may be passed. To pass a single scalar value, "send" a SCALAR reference to it, and dereference the result of "recv". CONSTRUCTOR
$channel = IO::Async::Channel->new Returns a new "IO::Async::Channel" object. This object reference itself should be shared by both sides of a "fork()"ed process. After "fork()" the two "setup_*" methods may be used to configure the object for operation on either end. While this object does in fact inherit from IO::Async::Notifier for implementation reasons it is not intended that this object be used as a Notifier. It should not be added to a Loop object directly; event management will be handled by its containing "IO::Async::Routine" object. METHODS
$channel->configure( %params ) Similar to the standard "configure" method on "IO::Async::Notifier", this is used to change details of the Channel's operation. on_recv => CODE May only be set on an async mode channel. If present, will be invoked whenever a new value is received, rather than using the "recv" method. $on_recv->( $channel, $data ) on_eof => CODE May only be set on an async mode channel. If present, will be invoked when the channel gets closed by the peer. $on_eof->( $channel ) $channel->send( $data ) Pushes the data stored in the given Perl reference into the FIFO of the Channel, where it can be received by the other end. When called on a synchronous mode Channel this method may block if a "write()" call on the underlying filehandle blocks. When called on an asynchronous mode channel this method will not block. $channel->send_frozen( $record ) A variant of the "send" method; this method pushes the byte record given. This should be the result of a call to "Storable::freeze()". $data = $channel->recv When called on a synchronous mode Channel this method will block until a Perl reference value is available from the other end and then return it. If the Channel is closed this method will return "undef". Since only references may be passed and all Perl references are true the truth of the result of this method can be used to detect that the channel is still open and has not yet been closed. $channel->recv( %args ) When called on an asynchronous mode Channel this method appends a callback function to the receiver queue to handle the next Perl reference value that becomes available from the other end. Takes the following named arguments: on_recv => CODE Called when a new Perl reference value is available. Will be passed the Channel object and the reference data. $on_recv->( $channel, $data ) on_eof => CODE Called if the Channel was closed before a new value was ready. Will be passed the Channel object. $on_eof->( $channel ) $channel->close Closes the channel. Causes a pending "recv" on the other end to return undef or the queued "on_eof" callbacks to be invoked. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::Channel(3pm)
All times are GMT -4. The time now is 02:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy