04-10-2013
Hello Scrutinizer,
Thank you for your help. It works just fine.
May you explain how is made the regexp for field separator. I understand that
this [ \t] means space or tab, but the next part, why not only one "|"?
Thanks again
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to find the top N entries for a certain field based on the values of another field.
For example if N=3, we want the 3 best values for each entry:
Entry1 ||| 100
Entry1 ||| 95
Entry1 ||| 30
Entry1 ||| 80
Entry1 ||| 50
Entry2 ||| 40
Entry2 ||| 20
Entry2 ||| 10
Entry2 ||| 50... (1 Reply)
Discussion started by: FrancoisCN
1 Replies
2. Shell Programming and Scripting
Hi,
I'm new to shell programming.
I have two variables a and b
a=val1
b=val2
could anyone kindly post the shell script to concatenate the values of variable a and b with an underscore(_) in between?
The final output should be val1_val2. (8 Replies)
Discussion started by: badrimohanty
8 Replies
3. Shell Programming and Scripting
Hi,
I have a huge text file. It looks like
abcde bangalo country 12345 lastfield
i want to get first 3 characters from field1 and first 3 characters from field 2 and insert the result as a new field. example the result should be:
abcde bangalo abcban country 12345 lastfield
Please... (4 Replies)
Discussion started by: ajithshankar@ho
4 Replies
4. Shell Programming and Scripting
I've got a long logfile of the form
network1:123:45:6789:01:234:56
network2:12:34:556:778:900:12
network3:...
I've got a similar logfile from a week later with different values for each of the fields eg
network1:130:50:6800:10:334:66
network2:18:40:600:800:999:20
network3:...
... (5 Replies)
Discussion started by: Yorkie99
5 Replies
5. Shell Programming and Scripting
Hello,
I have a text file with n lines in the following format (9 column fields):
Example:
contig00012 149606 G C 49 68 60 18 c$cccccacccccccccc^c
I need to count the number of lower-case and upper-case occurences in column 9, respectively, of the... (3 Replies)
Discussion started by: s052866
3 Replies
6. Shell Programming and Scripting
hi
i have file as below , i want to add duplicate records like bell_bb to one record with valuve as 15 ( addition of both )
any oneline awk script to achive this ?
header 0
CAMPAIGN_NAME 1
Bell_BB 14
Bell_MONTHLY 803
SOLO_UNBEATABLE 644
Bell_BB 1
Bell_MONTHLY 25
SOLO_UNBEATABLE... (4 Replies)
Discussion started by: raghavendra.cse
4 Replies
7. Shell Programming and Scripting
Hi,
I have a file like this
A Bob
A Sam
A John
B David
C Paul
C Sandra
If the consecutive field values in column one is same, then concatenate the corresponding strings.
So, I need an output like this,
A Bob_Sam_John
B David
C Paul_Sandra
I usually work with excel but... (3 Replies)
Discussion started by: polsum
3 Replies
8. Shell Programming and Scripting
Hi,
I have got a file comp_data containing the below data :
38232836|9302392|49
39203827|8203203,3933203|52
72832788|567,3245,2434324|100
This file can have many rows like shown above. I want the values separated by "," in second column(taking "|" as delimiter) to be in quotes. These... (2 Replies)
Discussion started by: msabhi
2 Replies
9. Shell Programming and Scripting
Table
ACN|NAME|CITY|CTY|NO1|NO2
115|AKKK|ASH|IND|10|15
115|AKKK|ASH|IND|20|20
115|AKKK|ASH|IND|30|35
115|AKKK|ASH|IND|30|35
112|ABC|FL|USA|15|15
112|ABC|FL|USA|25|20
112|ABC|FL|USA|25|45
i have written shell script using cut command
and awk programming getting error correct it and add... (5 Replies)
Discussion started by: udhal
5 Replies
10. UNIX for Beginners Questions & Answers
there can be n number of columns but the number of columns and header name will remain same in all 3 files. Files are tab Delimited.
a.txt
Name 9/1 9/2
X 1 7
y 2 8
z 3 9
a 4 10
b 5 11
c 6 12
b.xt
Name 9/1 9/2
X 13 19
y 14 20
z 15 21
a 16 22
b 17 23
c 18 24 c.txt
Name 9/1 9/2... (14 Replies)
Discussion started by: Nina2910
14 Replies
LEARN ABOUT MOJAVE
regexp::common::list
Regexp::Common::list(3) User Contributed Perl Documentation Regexp::Common::list(3)
NAME
Regexp::Common::list -- provide regexes for lists
SYNOPSIS
use Regexp::Common qw /list/;
while (<>) {
/$RE{list}{-pat => 'w+'}/ and print "List of words";
/$RE{list}{-pat => $RE{num}{real}}/ and print "List of numbers";
}
DESCRIPTION
Please consult the manual of Regexp::Common for a general description of the works of this interface.
Do not use this module directly, but load it via Regexp::Common.
$RE{list}{-pat}{-sep}{-lastsep}
Returns a pattern matching a list of (at least two) substrings.
If "-pat=P" is specified, it defines the pattern for each substring in the list. By default, P is "qr/.*?S/". In Regexp::Common 0.02 or
earlier, the default pattern was "qr/.*?/". But that will match a single space, causing unintended parsing of "a, b, and c" as a list of
four elements instead of 3 (with "-word" being "(?:and)"). One consequence is that a list of the form "a,,b" will no longer be parsed. Use
the pattern "qr /.*?/" to be able to parse this, but see the previous remark.
If "-sep=P" is specified, it defines the pattern P to be used as a separator between each pair of substrings in the list, except the final
two. By default P is "qr/s*,s*/".
If "-lastsep=P" is specified, it defines the pattern P to be used as a separator between the final two substrings in the list. By default
P is the same as the pattern specified by the "-sep" flag.
For example:
$RE{list}{-pat=>'w+'} # match a list of word chars
$RE{list}{-pat=>$RE{num}{real}} # match a list of numbers
$RE{list}{-sep=>" "} # match a tab-separated list
$RE{list}{-lastsep=>',s+ands+'} # match a proper English list
Under "-keep":
$1 captures the entire list
$2 captures the last separator
$RE{list}{conj}{-word=PATTERN}
An alias for $RE{list}{-lastsep=>'s*,?s*PATTERNs*'}
If "-word" is not specified, the default pattern is "qr/and|or/".
For example:
$RE{list}{conj}{-word=>'et'} # match Jean, Paul, et Satre
$RE{list}{conj}{-word=>'oder'} # match Bonn, Koln oder Hamburg
$RE{list}{and}
An alias for $RE{list}{conj}{-word=>'and'}
$RE{list}{or}
An alias for $RE{list}{conj}{-word=>'or'}
SEE ALSO
Regexp::Common for a general description of how to use this interface.
AUTHOR
Damian Conway (damian@conway.org)
MAINTAINANCE
This package is maintained by Abigail (regexp-common@abigail.be).
BUGS AND IRRITATIONS
Bound to be plenty.
For a start, there are many common regexes missing. Send them in to regexp-common@abigail.be.
LICENSE and COPYRIGHT
This software is Copyright (c) 2001 - 2009, Damian Conway and Abigail.
This module is free software, and maybe used under any of the following licenses:
1) The Perl Artistic License. See the file COPYRIGHT.AL.
2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2.
3) The BSD Licence. See the file COPYRIGHT.BSD.
4) The MIT Licence. See the file COPYRIGHT.MIT.
perl v5.18.2 2013-03-08 Regexp::Common::list(3)