Search Results

Search: Posts Made By: ncwxpanther
5,407
Posted By ncwxpanther
I found a solution that works for me. In my...
I found a solution that works for me. In my previous attempts I was not using an awk variable with -v. Thanks.

for id in {`cat counties.txt`}; do grep $id county-annual-average.txt > $id.txt;...
5,407
Posted By ncwxpanther
Rudi Id like to print the greatest $4 value...
Rudi

Id like to print the greatest $4 value less than the one in variables.txt but searching from the 2019 value in $3 in decreasing order, i.e., 2019, 2018, 2017...
5,407
Posted By ncwxpanther
For each ID in column 1 of the avgs.txt file, I...
For each ID in column 1 of the avgs.txt file, I need to match id's to find the lines in file-to-search.txt whose value in column 4 is the next lowest to the value in column 2 of the avgs.txt file...
5,407
Posted By ncwxpanther
Grepping for one variable while using awk to parse an associated variable
Im trying to search for a single variable in the first field and from that output use awk to extract out the lines that contain a value less than a value stored in another variable. Both the...
4,464
Posted By ncwxpanther
Issue with search and replacing multiple items in multiple files
Im having an issue when trying to replace the first column with a new set of values in multiple files. The results from the following code only replaces the files with the last set of values in...
1,843
Posted By ncwxpanther
Analyzing last 2 fields of 1 row and 3rd field of next row
I have the following script that will average the last two fields of each row, but im not sure how to include the 3rd field of the following row.

An example of the analysis that I need to perform...
3,367
Posted By ncwxpanther
Thanks Scrutinizer. The output is as desired.
Thanks Scrutinizer. The output is as desired.
3,367
Posted By ncwxpanther
These appear to be the same. Did I miss something?
These appear to be the same. Did I miss something?
3,367
Posted By ncwxpanther
Thanks for the help, but this prints out the...
Thanks for the help, but this prints out the first line for each unique ID. Not necessarily the min value.

Input

01001 011895 7.03 2.96 8.36 3.53 3.96 5.40 3.92 3.36 ...
3,367
Posted By ncwxpanther
I see. To be more specific I need the script to...
I see. To be more specific I need the script to look at each field separately for each unique ID. So the min value for just Field 3 or just Field 4.
3,367
Posted By ncwxpanther
fix awk ' !/-99.99/ {if (! t[$1]) t[$1]...
fix
awk '
!/-99.99/ {if (! t[$1]) t[$1] = $3
for(i = 3; i <= NF; i++) if (t[$1] > $i) {
t[$1] = $i; k[$1] = $2}
}
END { for...
3,367
Posted By ncwxpanther
Issue using awk to print min values for unique ids
I am using the following script to search for and print minimum values for each individual Fields (3-14) for each unique id (Field 1). But when the field contains a "-99.99" ( I am ignoring "-99.99")...
1,835
Posted By ncwxpanther
Thanks. This makes sense aside from the "NR > 1"...
Thanks. This makes sense aside from the "NR > 1" part. Does that make it start 1 line above?
1,835
Posted By ncwxpanther
For simplicity sake I originally wanted to...
For simplicity sake I originally wanted to average the output for 2016 and 2017. So (40.15 + 42.04 + 44.02)/3
I thought I would be able to simply expand it out to cover additional lines. There are...
1,835
Posted By ncwxpanther
You are correct. The data is sorted by field 1...
You are correct. The data is sorted by field 1 than field 2.

Can the code be modified to work across multiple fields for instance for values between 2015 and 2018? Much like the script you helped...
1,835
Posted By ncwxpanther
The records are sorted by field 2 then by field...
The records are sorted by field 2 then by field 1.

001001 2015 32.97 30.74 48.52 56.88 60.67 69.22 72.41 69.48 64.44 54.18 49.64 47.21
001001 2016 33.22 38.19 ...
1,835
Posted By ncwxpanther
Using the example that RudiC linked to - I know...
Using the example that RudiC linked to - I know how to get the average of fields 3 and 4, but Im not sure how to include field 14 in the calculation. The below script is not clean but appears to...
1,835
Posted By ncwxpanther
Compute average based on field values
Im looking for a way to average the values in field 14 (when field 2 is equal to 2016) and fields 3 and 4 (when field 2 is equal to 2017).

Any help is appreciated.


001001 2016 33.22 ...
1,768
Posted By ncwxpanther
Oh I see. Thats the first time I have had to...
Oh I see. Thats the first time I have had to enter the input file twice. At first glance it appears to work as you said. Thanks for the help with this one!
1,768
Posted By ncwxpanther
My apologies for the lack of information. ...
My apologies for the lack of information.

GNU Awk 3.1.7
Linux CentOS release 6.9 (Final)

Would the format of the input cause the issue? There is a single space between each field.
1,768
Posted By ncwxpanther
I have played around with this but could not get...
I have played around with this but could not get anything to output.
1,768
Posted By ncwxpanther
Average select rows
I have no idea how to even get started with this script.

I need to average field 3 for each of the unique identifiers found in field 1. However, I only want to average these rows when field 2 is...
1,744
Posted By ncwxpanther
Thanks! I was able to get this to perform as...
Thanks!
I was able to get this to perform as expected

awk '{ print substr($1,53,11) " " $16}' file.txt
1,744
Posted By ncwxpanther
Parsing out data with multiple field separators
I have a large file that I need to print certain sections out of.

file.txt

/alpha/beta/delta/gamma/425/590/USC00015420.blah.lt.0.01.str:USC00015420Y2017M10BLALT.01 12 13 14 -9 1 ...
1,627
Posted By ncwxpanther
Thanks to both of you. I incorporated both...
Thanks to both of you.

I incorporated both your suggestions and had to create a tab separation between 37 -84 This is what I think will work for the long term.


awk -v OFS="\t" '{
...
Showing results 1 to 25 of 152

 
All times are GMT -4. The time now is 07:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy