Sponsored Content
Full Discussion: Variable filtering in awk
Top Forums Shell Programming and Scripting Variable filtering in awk Post 302844935 by gio001 on Tuesday 20th of August 2013 11:11:39 AM
Old 08-20-2013
Variable filtering in awk

Hello all,
can you explain why this filter does not work, it prints all the lines in the file:
Code:
awk -v sel="TestString" 'sel'  file

while these work:
Code:
awk '/TestString/' file
awk -v sel="TestString" '$0~sel'  file

Thanks!Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

awk filtering ?

I have a Ques. Regarding awk I have few strings in a file, like.. ABC DEF_ABC GHI_ABC GHI Now I want string which has only 'ABC', not the part of any other string as it is also present in 'DEF_ABC' Output should be ABC Please guide me asap !! Thanks :b: (4 Replies)
Discussion started by: varungupta
4 Replies

2. Shell Programming and Scripting

Filtering some data and storing the remaing to a variable.

Hi, i have a problem writing a script. Actually i have many files which contains some data, now the last line has some data as in the format : 2556||04-04-10 now i want to do tail -1 filename.txt and store the result into a variable which will be used later for some other calculations. My... (7 Replies)
Discussion started by: fidelis
7 Replies

3. Shell Programming and Scripting

awk filtering, then execution

Hi, I need to do the following but I don't know exactly what to do. I need to monitor a file ... with tail -f for example, but I know that I could do it with awk, wait for a specific string ... , then perform an action, call a script, etc. Let's say that my file name is test.txt , I need... (3 Replies)
Discussion started by: ocramas
3 Replies

4. Shell Programming and Scripting

Filtering out text with awk

(0 Replies)
Discussion started by: nilekyle
0 Replies

5. Shell Programming and Scripting

Filtering data using AWK

Hi , i have file with delimiter as "|" and data in Double codes for all fields. how to filter data in a column like awk -F"|" '$1="asdf" {print $0}' test. ex : "asdf"|"zxcv" Thanks, Soma (1 Reply)
Discussion started by: challamsomu
1 Replies

6. Shell Programming and Scripting

filtering with awk

i have question about awk ex: input.txt 1252468812,yahoo,3.5 1252468812,hotmail,2.4 1252468819,yahoo,1.2 msn,1252468812,8.9 1252468923,gmail,12 live,1252468812,3.4 yahoo,1252468812,9.0 1252468929,msn,1.2 output.txt 1252468812,yahoo,3.5 1252468812,hotmail,2.4 msn,1252468812,8.9... (3 Replies)
Discussion started by: zvtral
3 Replies

7. Shell Programming and Scripting

filtering awk not using grep

hallow all i have question about awk i want indexing last key (in BOLD number) ex: input.txt 1 252468812 52468812 1281268819 1252468812 1252468923 468812 1252468812 so output will like this output text 1:252468812 2:52468812 4:1252468812 6:468812 7:1252468812 output get... (8 Replies)
Discussion started by: zvtral
8 Replies

8. Shell Programming and Scripting

filtering a numeric value which has '%' using awk

Hello Gurus, I have a requirement where I have to filter a value from some field which has 99% or greater than '99%'.. For ex: The Date (file -- sample.csv) will be like below Field1,Field2,Field3,Field4 860440512,844284992,16155520,99% 860440512,844284992,16155520,94%... (4 Replies)
Discussion started by: raghu.iv85
4 Replies

9. Shell Programming and Scripting

Filtering values in variable

Hi, is there a faster/simpler way to filter values from the variable1 in variable2? example: variable1="A|B|C|E" variable2="A|B|C|D|F" output: "A|B|C" Thanks, zzavilz (4 Replies)
Discussion started by: zzavilz
4 Replies

10. UNIX for Beginners Questions & Answers

Filtering text with awk

I need to filter a file that is composed like that: >Cluster 0 0 292nt, >last294258;size=1;... * >Cluster 1 0 292nt, >last111510;size=1;... * 1 290nt, >last136280;size=1;... at -/98.62% 2 292nt, >last217336;size=1;... at +/99.66% 3 292nt, >last280937;size=1;... at -/99.32% >Cluster 2... (6 Replies)
Discussion started by: pedro88
6 Replies
Net::HTTPS::NB(3pm)					User Contributed Perl Documentation				       Net::HTTPS::NB(3pm)

NAME
Net::HTTPS::NB - Non-blocking HTTPS client SYNOPSIS
Example from Net::HTTP::NB use Net::HTTPS::NB; use IO::Select; use strict; my $s = Net::HTTPS::NB->new(Host => "pause.perl.org") || die $@; $s->write_request(GET => "/"); my $sel = IO::Select->new($s); READ_HEADER: { die "Header timeout" unless $sel->can_read(10); my($code, $mess, %h) = $s->read_response_headers; redo READ_HEADER unless $code; } while(1) { die "Body timeout" unless $sel->can_read(10); my $buf; my $n = $s->read_entity_body($buf, 1024); last unless $n; print $buf; } Example of non-blocking connect use strict; use Net::HTTPS::NB; use IO::Select; my $sock = Net::HTTPS::NB->new(Host => 'encrypted.google.com', Blocking => 0); my $sele = IO::Select->new($sock); until ($sock->connected) { if ($HTTPS_ERROR == HTTPS_WANT_READ) { $sele->can_read(); } elsif($HTTPS_ERROR == HTTPS_WANT_WRITE) { $sele->can_write(); } else { die 'Unknown error: ', $HTTPS_ERROR; } } See `examples' subdirectory for more examples. DESCRIPTION
Same interface as Net::HTTPS but it will never try multiple reads when the read_response_headers() or read_entity_body() methods are invoked. In addition allows non-blocking connect. If read_response_headers() did not see enough data to complete the headers an empty list is returned. If read_entity_body() did not see new entity data in its read the value -1 is returned. PACKAGE CONSTANTS
Imported by default HTTPS_WANT_READ HTTPS_WANT_WRITE PACKAGE VARIABLES
Imported by default $HTTPS_ERROR METHODS
new(%cfg) Same as Net::HTTPS::new, but in addition allows `Blocking' parameter. By setting this parameter to 0 you can perform non-blocking connect. See connected() to determine when connection completed. connected() Returns true value when connection completed (https handshake done). Otherwise returns false. In this case you can check $HTTPS_ERROR to determine what handshake need for, read or write. $HTTPS_ERROR could be HTTPS_NEED_READ or HTTPS_NEED_WRITE respectively. See "SYNOPSIS". blocking($flag) As opposed to Net::HTTPS where blocking method consciously broken you can set socket blocking. For example you can return socket to blocking state after non-blocking connect. SEE ALSO
Net::HTTP, Net::HTTP::NB COPYRIGHT
Copyright 2011 Oleg G <oleg@cpan.org>. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-06-07 Net::HTTPS::NB(3pm)
All times are GMT -4. The time now is 08:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy