Sponsored Content
Top Forums Shell Programming and Scripting Value falls between two values from different files Post 302772777 by Chubler_XL on Tuesday 26th of February 2013 08:23:05 PM
Old 02-26-2013
How about this:

Code:
awk 'NR==FNR{
   C[NR]=$1 " " $2
   L[C[NR]]=0
   next
}
{
 for (t in C) {
    split(C[t],v," ")
    if($1>=v[1] && $1<=v[2])
       L[C[t]]+=$2
 }
}
END {
   for(i=1;i in C;i++)
       print C[i] " " L[C[i]]
}' 2 1

These 2 Users Gave Thanks to Chubler_XL For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk substring falls between two values

Hi guys, hopefully you can give me a hand with this before my monitor has a nasty accident! :mad: I have the following line in a script: awk 'int(substr($1,2,2))>'06' && int(substr($1,2,2))<'08' ' ANYOLDFILE.log ... which when ran against this data file: ... correctly... (3 Replies)
Discussion started by: dlam
3 Replies

2. BSD

Remote connections unable after power falls

Hi everyone: I have a server used for testing running FreeBSD, last weekend we had power cuts in my job and our server was constantly rebooting. since then the network connections are very slow, it's almost impossible establish a remote connection with the server, however running any... (2 Replies)
Discussion started by: edgarvm
2 Replies

3. Shell Programming and Scripting

Cat Values from Several files if it meets criteria for column values

I have results from some statistical analyses. The format of the results are as given below: I want to select lines that have a p-value (last column) less than 0.05 from all the results files (*.results) and cat to a new results file. It would be very nice if a new column is added that tells... (2 Replies)
Discussion started by: genehunter
2 Replies

4. Shell Programming and Scripting

How to get the next word which falls just after a keyword?

Hi friends, i just want to know the command though which i can get the next word which comes just after a particluar keyword. For example: suppose text.out is file which contains a pl/sql procedure . i want to find out the word which falls just after the "table1" keyword. Thank... (7 Replies)
Discussion started by: neelmani
7 Replies

5. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

6. Shell Programming and Scripting

how to get a worrd which falls after a keyword separated by comma

Hi friends, i have a file which contains all words(including comma) in different line. for example: more file.txt select column1 from table1 , table2 join table3 0n condition i just want to get table2 if there is a comma after table1(as shown in the above case) else dont fetch... (4 Replies)
Discussion started by: neelmani
4 Replies

7. Emergency UNIX and Linux Support

How to move files from a directory which falls between Date Range?

Hi All, I am trying to to move files from a directory to another which falls from Current day - 7 days. The files are in zipped format with dates appended on it. Can you pls help me as this came as a immediate change before the production Release planned next week. Pls let me know if... (11 Replies)
Discussion started by: dsfreddie
11 Replies

8. Shell Programming and Scripting

Query the table and return values to shell script and search result values from another files.

Hi, I need a shell script, which would search the result values from another files. 1)execute " select column1 from table_name" query on the table. 2)Based on the result, need to be grep from .wft files. could please explain about this.Below is the way i am using. #!/bin/sh... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

9. UNIX for Beginners Questions & Answers

Replace Stub Values In One Group Of Files With Actual Values From Another Group Of Files

I have two directories of files (new-config-files and old-config-files): new-config-files/this-db/config.inc.php new-config-files/that-db/config.inc.php new-config-files/old-db/config.inc.php new-config-files/new-db/config.inc.php new-config-files/random-database/config.inc.php etc. ... (4 Replies)
Discussion started by: spacegoose
4 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 11:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy