04-26-2013
Hi there,
you would do well if you could explain the requirement in plain English. Those $0's, $1's, etc. only confuse a reader and make your intent difficult to understand.
You could post a sample by redacting the sensitive portions.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I need to grep for a pattern in a file. Files are huge and have several repeated occurances of the strings which match pattern. I just need the strings which contain the pattern in the output.
For eg.
The contents of my file are as follows. The pattern I want to match by is ABCD
... (5 Replies)
Discussion started by: tektips
5 Replies
2. Shell Programming and Scripting
Hi all,
I want to write a awk script that counts unique IPs that have received one special error.
For example
25-04-2012;192.168.70.31;1254545454545417;500.0;SUCCESS
25-04-2012;192.168.70.32;355666650914;315126423993;;General_ERROR_23
30-04-2012;192.168.70.33;e;null;null;Failure... (2 Replies)
Discussion started by: arrals_vl
2 Replies
3. Shell Programming and Scripting
Hi, I have tab-deliminated data similar to the following:
dot is-big 2
dot is-round 3
dot is-gray 4
cat is-big 3
hot in-summer 5
I want to count the frequency of each individual "unique" value in the 1st column. Thus, the desired output would be as follows:
dot 3
cat 1
hot 1
is... (5 Replies)
Discussion started by: owwow14
5 Replies
4. Shell Programming and Scripting
Im looking for an awk script that will take the unique values in column 5, then print and count the unique values in column 6.
CA001011500 11111 11111 -9999 201301 AAA
CA001012040 11111 11111 -9999 201301 AAA
CA001012573 11111 11111 -9999 201301 BBB
CA001012710 11111 11111 -9999 201301... (4 Replies)
Discussion started by: ncwxpanther
4 Replies
5. Shell Programming and Scripting
Trying to get the unique count of the below input, but if the text in beginning of $5 is a partial match to another line in the file then it is not unique.
awk
awk '!seen++ {n++} END {print n}' input
7 input
chr1 159174749 159174770 chr1:159174749-159174770 ACKR1
chr1 ... (2 Replies)
Discussion started by: cmccabe
2 Replies
6. Shell Programming and Scripting
Hello Team,
I need your help on the following:
My input file a.txt is as below:
3330690|373846|108471
3330690|373846|108471
0640829|459725|100001
0640829|459725|100001
3330690|373847|108471
Here row 1 and row 2 of column 1 are identical but corresponding column 2 value are... (4 Replies)
Discussion started by: angshuman
4 Replies
7. UNIX for Beginners Questions & Answers
Hi,
tab-separated input:
blabla_1 A,B,C,C
blabla_2 A,E,G
blabla_3 R,Q,A,B,C,R,Q
output:
blabla_1 3
blabla_2 3
blabla_3 5
After splitting $2 in an array, I am trying to store the number of unique elements in a variable, but have some difficulties resetting the variable to 0 before... (6 Replies)
Discussion started by: beca123456
6 Replies
8. UNIX for Beginners Questions & Answers
Hello,
I am trying to count unique rows in my file based on 4 columns (2-5) and to output its frequency in a sixth column. My file is tab delimited
My input file looks like this:
Colum1 Colum2 Colum3 Colum4 Coulmn5
1.1 100 100 a b
1.1 100 100 a c
1.2 200 205 a d
1.3 300 301 a y
1.3 300... (6 Replies)
Discussion started by: nans
6 Replies
9. Shell Programming and Scripting
What is an efficient way of counting the number of unique values in a 400 column by 1000 row array and outputting the counts per column, assuming the unique values in the array are:
A, B, C, D
In other words the output should look like: Value COL1 COL2 COL3
A 50 51 52... (16 Replies)
Discussion started by: Geneanalyst
16 Replies
10. Shell Programming and Scripting
My command sed will modify everything in column 3 if i will use the command below. I want to search for a pattern then modify everything in column 3.
sed -i 's/\|165\|/server1/g' file.txt
Input:
01-31-2019 19:14:05|device|165|1548962040165|5c5348f9-0804-1111|file_attach|7271|587|smtp|... (6 Replies)
Discussion started by: invinzin21
6 Replies
LEARN ABOUT DEBIAN
web::dispatch::httpmethods
Web::Dispatch::HTTPMethods(3pm) User Contributed Perl Documentation Web::Dispatch::HTTPMethods(3pm)
NAME
Web::Dispatch::HTTPMethods - Helpers to make RESTFul Dispatchers Easier
SYNOPSIS
package MyApp:WithHTTPMethods;
use Web::Simple;
use Web::Dispatch::HTTPMethods;
sub as_text {
[200, ['Content-Type' => 'text/plain'],
[$_[0]->{REQUEST_METHOD}, $_[0]->{REQUEST_URI}] ]
}
sub dispatch_request {
sub (/get) {
GET { as_text(pop) }
},
sub (/get-head) {
GET { as_text(pop) }
HEAD { [204,[],[]] },
},
sub (/get-post-put) {
GET { as_text(pop) } ## NOTE: no commas separating http methods
POST { as_text(pop) }
PUT { as_text(pop) }
},
}
DESCRIPTION
Exports the most commonly used HTTP methods as subroutine helps into your Web::Simple based application. Additionally adds an automatic
HTTP code 405 "Method Not Allow" if none of the HTTP methods match for a given dispatch and also adds a dispatch rule for "HEAD" if no
"HEAD" exists but a "GET" does (in which case the "HEAD" returns the "GET" dispatch with an empty body.)
We also add at the end of the chain support for the OPTIONS method (if you do not add one yourself. This defaults to http 200 ok + Allows
http headers.
Also we try to set correct HTTP headers such as "Allows" as makes sense based on your dispatch chain.
The following dispatch chains are basically the same:
sub dispatch_request {
sub (/get-http-methods) {
GET { [200, ['Content-Type' => 'text/plain'], ['Hello World']] }
},
sub(/get-classic) {
sub (GET) { [200, ['Content-Type' => 'text/plain'], ['Hello World']] },
sub (HEAD) { [200, ['Content-Type' => 'text/plain'], []] },
sub (OPTIONS) {
[200, ['Content-Type' => 'text/plain', Allows=>'GET,HEAD,OPTIONS'], []];
},
sub () {
[405, ['Content-Type' => 'text/plain', Allows=>'GET,HEAD,OPTIONS'],
['Method Not Allowed']]
},
}
}
The idea here is less boilerplate to distract the reader from the main point of the code and also to encapsulate some best practices.
NOTE You currently cannot mix http method style and prototype sub style in the same scope, as in the following example:
sub dispatch_request {
sub (/get-head) {
GET { ... }
sub (HEAD) { ... }
},
}
If you try this our code will notice and issue a "die". If you have a good use case please bring it to the authors.
EXPORTS
This automatically exports the following subroutines:
GET
PUT
POST
HEAD
DELETE
OPTIONS
AUTHOR
See Web::Simple for AUTHOR
CONTRIBUTORS
See Web::Simple for CONTRIBUTORS
COPYRIGHT
See Web::Simple for COPYRIGHT
LICENSE
See Web::Simple for LICENSE
perl v5.14.2 2012-05-07 Web::Dispatch::HTTPMethods(3pm)