Sponsored Content
Top Forums Shell Programming and Scripting Awk numeric range match only one digit? Post 302569822 by meridionaljet on Tuesday 1st of November 2011 04:26:54 PM
Old 11-01-2011
Quote:
Originally Posted by Corona688
Try comparing $2 as a number, not a regex.

Code:
awk 'BEGIN { MIN=1; MAX=9; }
($2 >= MIN) && ($2 <= MAX)'

The { print $0 } is redundant if all you want is print $0. That's what happens by default given no code block.

---------- Post updated at 01:38 PM ---------- Previous update was at 01:36 PM ----------

Also, if you have -v, that's a safer and simpler way to get variables into awk:

Code:
awk -v MIN=1 -v MAX=9 '($2 >= MIN)&&($2 <= MAX)'

Thank you very much. This is the framework I needed.
This User Gave Thanks to meridionaljet For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

numeric range comparisons

I have two files.And a sort of matrix analysis. Both files have a string followed by two numbers: File 1: A 2 7 B 3 11 C 5 10 ...... File 2: X 1 10 Y 3 5 Z 5 9 What I'd like to do is for each set of numbers in the second file indicate if the first or second number (or both) in... (7 Replies)
Discussion started by: dcfargo
7 Replies

2. Shell Programming and Scripting

match range of different numbers by AWK

if the column1 and 2 in both files has same key (for example "a" and "a1") compare each first key value(a1 of a) of input2 (for example 1-4 or 65-69 not 70-100 or 44-40 etc) with all the values in input1. if the range of first key value in input2 is outof range in input1 values named it as out... (54 Replies)
Discussion started by: repinementer
54 Replies

3. Shell Programming and Scripting

awk to match a numeric range specified by two columns

Hi Everyone, Here's a snippet of my data: File 1 = testRef2: A1BG - 13208 13284 AAA1 - 34758475 34873943 AAAS - 53701240 53715412File 2 = 42MLN.3.bedS2: 13208 13208 13360 13363 13484 13518 13518My awk script: awk 'NR == FNR{a=$1;next} {$1>=a}{$1<=a}{print... (5 Replies)
Discussion started by: heecha
5 Replies

4. Programming

Perl : Numeric Range Pattern Matching

hi Experts just wondering if you can help me check a number between a specific range if i have an ip address , how can i say the valid number for ip between 1 to 254 something like this if ($ip ) =~ /.../ { } what the pattern i need to type thanks (3 Replies)
Discussion started by: doubando
3 Replies

5. Shell Programming and Scripting

awk length of digit and print at most right digit

Have columns with digits and strings like: input.txt 3840 3841 3842 Dav Thun Tax Cahn 146; Dav. 3855 3853 3861 3862 Dav Thun Tax 2780 Karl VI., 3873 3872 3872 Dav Thun Tax 3894 3893 3897 3899 Dav Thun Tax 403; Thun 282. 3958 3959 3960 Dav Thun Tax 3972 3972 3972 3975 Dav Thun Tax... (8 Replies)
Discussion started by: sdf
8 Replies

6. Shell Programming and Scripting

Zipping files by numeric name range

Hi there, Not being too up on bash shell programming at this point, could anyone throw me a bone about how to zip up a set of numerically-named files by range? For example, in a folder that contains files 1.pdf through 132000.pdf, I'd like to zip up just those files that are 50000.pdf and... (6 Replies)
Discussion started by: enwood
6 Replies

7. Shell Programming and Scripting

awk to update specific value in file with match and add +1 to specific digit

I am trying to use awk to match the NM_ in file with $1 of id which is tab-delimited. The NM_ will always be in the line of file that starts with > and be after the second _. When there is a match between each NM_ and id, then the value of $2 in id is substituted or used to update the NM_. Each NM_... (3 Replies)
Discussion started by: cmccabe
3 Replies

8. Shell Programming and Scripting

Get range out using sed or awk, only if given pattern match

Input: START OS:: UNIX Release: xxx Version: xxx END START OS:: LINUX Release: xxx Version: xxx END START OS:: Windows Release: xxx Version: xxx ENDHere i am trying to get all the information between START and END, only if i could match OS Type. I can get all the data between the... (3 Replies)
Discussion started by: Dharmaraja
3 Replies

9. Shell Programming and Scripting

awk to print text in field if match and range is met

In the awk below I am trying to match the value in $4 of file1 with the split value from $4 in file2. I store the value of $4 in file1 in A and the split value (using the _ for the split) in array. I then strore the value in $2 as min, the value in $3 as max, and the value in $1 as chr. If A is... (6 Replies)
Discussion started by: cmccabe
6 Replies

10. UNIX for Beginners Questions & Answers

I need to find in a file a list of number where last two digit end in a range

I all I am tryng to find a way to sort a list of number in a file by the value of last two digit. i have a list like this 313202320388 333202171199 373202164587 393202143736 323202132208 353201918107 343201887399 363201810249 333201805043 353201791691 (7 Replies)
Discussion started by: rattoeur
7 Replies
poterminology(1)					      Translate Toolkit 1.9.0						  poterminology(1)

NAME
poterminology - reads a set of .po or .pot files to produce a pootle-terminology.pot SYNOPSIS
poterminology [--version] [-h|--help] [--manpage] [--progress PROGRESS] [--errorlevel ERRORLEVEL] [-i|--input] INPUT [-x|--exclude EXCLUDE] [-o|--output] OUTPUT [-u|--update UPDATEFILE] [-S|--stopword-list STOPFILE] [-F|--fold-titlecase] [-C|--preserve-case] [-I|--ignore-case] [--accelerator ACCELERATORS] [-t|--term-words LENGTH] [--nonstop-needed MIN] [--inputs-needed MIN] [--fullmsg-needed MIN] [--substr-needed MIN] [--locs-needed MIN] [--sort ORDER] [--source-language LANG] [-v|--invert] DESCRIPTION
See: http://translate.sourceforge.net/wiki/toolkit/poterminology for examples and usage instructions OPTIONS
--version show program's version number and exit -h/--help show this help message and exit --manpage output a manpage based on the help --progress show progress as: dots, none, bar, names, verbose --errorlevel show errorlevel as: none, message, exception, traceback -i/--input read from INPUT in pot, po formats -x/--exclude exclude names matching EXCLUDE from input paths -o/--output write to OUTPUT in po, pot formats -u/--update update terminology in UPDATEFILE -S/--stopword-list read stopword (term exclusion) list from STOPFILE (default /usr/share/pyshared/translate/share/stoplist-en) -F/--fold-titlecase fold "Title Case" to lowercase (default) -C/--preserve-case preserve all uppercase/lowercase -I/--ignore-case make all terms lowercase --accelerator ignores the given accelerator characters when matching -t/--term-words generate terms of up to LENGTH words (default 3) --nonstop-needed omit terms with less than MIN nonstop words (default 1) --inputs-needed omit terms appearing in less than MIN input files (default 2, or 1 if only one input file) --fullmsg-needed omit full message terms appearing in less than MIN different messages (default 1) --substr-needed omit substring-only terms appearing in less than MIN different messages (default 2) --locs-needed omit terms appearing in less than MIN different original source files (default 2) --sort output sort order(s): frequency, dictionary, length (default is all orders in the above priority) --source-language the source language code (default 'en') -v/--invert invert the source and target languages for terminology Translate Toolkit 1.9.0 poterminology(1)
All times are GMT -4. The time now is 11:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy