Sponsored Content
Top Forums Shell Programming and Scripting select lines with certain values on certain fields with awk Post 302706623 by Scrutinizer on Thursday 27th of September 2012 04:56:29 AM
Old 09-27-2012
Assuming your field separator equals " | " (space-pipe-space), try:
Code:
awk -F ' \\| ' '$2~/^10\.216\.22\.(XX|YY|ZZ)$/ && $4~/^[0-9]+$/' file

This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

printing select fields in awk

Hi, I want to print certain fields from my data file depending on certain conditions. Somebody pls let me know how to send it to awk. The command below is the one which I want to use in a shell script and this prints fine cat ./datafile.dat | grep -i $SEARCH_STR | awk -F: '{ print $1 $2 $3... (5 Replies)
Discussion started by: maverix
5 Replies

2. Shell Programming and Scripting

awk with fields select?

If i have a log file record.txt, with 10 fields - First field is datetime - 7th field is status - 8th filed is name - The last field (10th) is epoch time of the first field 02/17/2012 1:47 PM||||||In Use|chicken||1329515230 02/17/2012 2:53 PM||||||Available|chicken||1329519195 02/17/2012... (4 Replies)
Discussion started by: sabercats
4 Replies

3. UNIX for Dummies Questions & Answers

Compare values of fields from same column with awk

Hi all ! If there is only one single value in a column (e.g. column 1 below), then return this value in the same output column. If there are several values in the same column (e.g. column 2 below), then return the different values separated by "," in the output. pipe-separated input: ... (11 Replies)
Discussion started by: lucasvs
11 Replies

4. Shell Programming and Scripting

awk - mixed for and if to select particular lines in a data file

Hi all, I am new to AWK and I am trying to solve a problem that is probably easy for an expert. Suppose I have the following data file input.txt: 20 35 43 20 23 54 20 62 21 20.5 43 12 20.5 33 11 20.5 89 87 21 33 20 21 22 21 21 56 87 I want to select from all lines having the... (4 Replies)
Discussion started by: naska
4 Replies

5. Shell Programming and Scripting

awk to extract multiple values from file and add two additional fields

In the attached file I am trying to use awk to extract multiple values and create the tab-delimited desired output. In the output R_Index is a the sequential # and Pre_Enrichment is defaulted to .. I can extract from the values to the side of the keywords, but most are above and I can not... (2 Replies)
Discussion started by: cmccabe
2 Replies

6. Shell Programming and Scripting

awk to print line is values between two fields in separate file

I am trying to use awk to find all the $3 values in file2 that are between $2 and $3 in file1. If a value in $3 of file2 is between the file1 fields then it is printed along with the $6 value in file1. Both file1 and file2 are tab-delimited as well as the desired output. If there is nothing to... (4 Replies)
Discussion started by: cmccabe
4 Replies

7. Shell Programming and Scripting

awk to select lines with maximum value of each record based on column value

Hello, I want to get the maximum value of each record separated by empty line based on the 3rd column of each row within each record? Input: A1 chr5D 634 7 82 707 A2 chr5D 637 6 82 713 A3 chr5D 637 5 82 713 A4 chr5D 626 1 82 704... (4 Replies)
Discussion started by: yifangt
4 Replies

8. Shell Programming and Scripting

awk to combine lines if fields match in lines

In the awk below, what I am attempting to do is check each line in the tab-delimeted input, which has ~20 lines in it, for a keyword SVTYPE=Fusion. If the keyword is found I am splitting $3 using the . (dot) and reading the portion before and after the dot in an array a. If it does have that... (12 Replies)
Discussion started by: cmccabe
12 Replies

9. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies

10. Shell Programming and Scripting

awk move select fields to match file prefix in two directories

In the awk below I am trying to use the file1 as a match to file2. In file2 the contents of $5,&6,and $7 (always tab-delimited) and are copied to the output under the header Quality metrics. The below executes but the output is empty. I have added comments to help and show my thinking. Thank you... (0 Replies)
Discussion started by: cmccabe
0 Replies
Image::Seek(3pm)					User Contributed Perl Documentation					  Image::Seek(3pm)

NAME
Image::Seek - A port of ImgSeek to Perl DESCRIPTION
use Image::Seek qw(loaddb add_image query_id savedb); loaddb("haar.db"); # EITHER my $img = GD::Image->newFromJpeg("photo-216.jpg", 1); # OR my $img = Imager->new(); $img->open(file => "photo-216.jpg"); # OR my $img = Image::Imlib2->load("photo-216.jpg"); # Then... add_image($img, 216); savedb("haar.db"); my @results = query_id(216); # What looks like this photo? remove_id(216); # Just remove id from database. DESCRIPTION
ImgSeek (http://www.imgseek.net/) is an implementation of Haar wavelet decomposition techniques to find similar pictures in a library. This module is port of the ImgSeek library to Perl's XS. It can deal with image objects produced by the "Imager" and "Image::Imlib2" libraries. EXPORT
None by default, but the following functions are available: savedb($file) Dumps the state of the norms and image buckets to the file $file. loaddb($file) Loads a database of image norms produced by savedb cleardb Clears the internal database. Note that "loaddb" will load into memory a bunch of data that you may already have - it will duplicate rather than replace this data, so results will be skewed if you load a database multiple times without clearing it in between. add_image($image, $id) Adds the image object to the database, keyed against the numeric id $id. This will compute the Haar transformation for a 128x128 thumbnail of the image, and then store its norms into a database in memory. remove_id($id) remove id from database, and you should "savedb" to save the changed database. query_id($id[, $results)) This queries the internal database for pictures which are "like" number $id. It returns a list of $results results (by default, 10); a result is an array reference. The first element is the ID of a picture, the second is a score. So for example: query_id(2481, 5) returns, in a shoot I have, the following: [ 2481, -38.3800003528595 ], [ 2480, -37.5519620793145 ], [ 2478, -37.39896965962 ], [ 2479, -37.2777427507208 ], [ 2584, -10.0803730081134 ], [ 2795, -7.89326129961427 ] Notice that the scores go the opposite way to what you might imagine: lower is better. The results come out sorted, and the first result is the thing you queried for. SEE ALSO
http://www.imgseek.net/ AUTHOR
Simon Cozens, <simon@cpan.org> Lilo Huang, <kenwu@cpan.org> All the clever bits were written by Ricardo Niederberger Cabral; I just mangled them to wrap Perl around them. COPYRIGHT AND LICENSE
Copyright (C) 2005 by Simon Cozens, 2008 by Lilo Huang This library is free software; as it is a derivative work of imgseek, this library is distributed under the same terms (GPL) as imgseek. perl v5.14.2 2008-02-09 Image::Seek(3pm)
All times are GMT -4. The time now is 07:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy