Sponsored Content
Top Forums Shell Programming and Scripting awk command: column operations Post 302447540 by shashi792 on Monday 23rd of August 2010 01:08:02 PM
Old 08-23-2010
awk command: column operations

I have a txt file with two columns

Code:
Freq    Loss
10         30
20         40
30         10
40         50
50         60

i have used the below code to get the minimum value out of this array in second cloumn.

Code:
awk 'NR==N{min=$N;max=$N}NR>N{if ($N>max){max=$N};if ($N<min){min=$N}}END {print ""min" "max}' $dummyfile.arr

my code finds out the minimum in second coulmn, but

1) I want to get correcponding Freq for tht minimum value

---------- Post updated at 12:08 PM ---------- Previous update was at 12:06 PM ----------

I want to output that freq to a txt file
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

command for a series of operations

I want to append a file containing a list of names and the sorted contents of the file should be copied to a new file. All this should be on a single line( using pipes and redirection) Pls help .. thankyou (1 Reply)
Discussion started by: phiber_optik
1 Replies

2. Shell Programming and Scripting

Masking a column using awk command

Thanks...It was a spoiler for my Team... (5 Replies)
Discussion started by: Diggi
5 Replies

3. Shell Programming and Scripting

Help With Array Operations in AWK

I have two files file1 A 2 4 6 8 B 1 3 5 7 C 1 3 5 7 D 1 3 5 7 E 1 3 5 7 file2 C D E F G H I J K L I need to add field 1 of file1 to both field 2s of file2 and repeat the same on all the rows in... (2 Replies)
Discussion started by: cold_Que
2 Replies

4. Shell Programming and Scripting

awk command - column merging

I have two files having 3 coulms and 1 column respectively file1.txt 0 22.89 35.60 10 22.80 35.61 20 22.70 35.63 30 22.32 35.68 50 19.23 35.79 75 16.10 35.59 100 15.00 35.52 125 14.45 35.46 150 13.91 35.41 200 12.94 35.28 ... (7 Replies)
Discussion started by: shashi792
7 Replies

5. UNIX for Dummies Questions & Answers

arithmetic operations on 1 column of a file

Hi, I have a file with thousands of lines like this: Chr1 477515 . ACCCC ACCC 17.7 . INDEL;DP=17;AF1=1;CI95=0.5,1;DP4=0,1,0,3;MQ=32;PV4=1,0.036,1,1 Chr1 481987 . A AAAT 62 . INDEL;DP=11;AF1=1;CI95=0.5,1;DP4=0,0,1,3;MQ=41 I want to make a file with... (2 Replies)
Discussion started by: fadista
2 Replies

6. Shell Programming and Scripting

how to do arithmetic operations in one line command

I have a file like this product qty1 qty2 value cola 50 25 1 pepsi 100 75 2 muffin 25 30 0.5 would like to do the following operations with one line command 1) disply the line having "Qty1" greater than or equal to 50 2) display the line Qty1 - Qty2 ... (2 Replies)
Discussion started by: johnveslin
2 Replies

7. Shell Programming and Scripting

Arthmetic & Operations Using AWK

Trying to do math while using awk and if statements. awk 'BEGIN {FS = ":"} ; {if($2=1) {$3 +=}; print "Total employee work hours: " $3}' works_on.txt The file format is 123456789:1:32.5 123456789:2:7.5 666884444:3:40.0 453453453:1:20.0 453453453:2:20.0 333445555:2:10.0 ... (6 Replies)
Discussion started by: Rapcher
6 Replies

8. Shell Programming and Scripting

awk command to print only selected rows in a particular column specified by column name

Dear All, I have a data file input.csv like below. (Only five column shown here for example.) Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 3,2,4,5,6 5,3,5,5,6 From this I want the below output Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 where the second column... (4 Replies)
Discussion started by: ks_reddy
4 Replies

9. Shell Programming and Scripting

How to Replace the value of a column using awk command?

Hi cat test.txt H|123|341|567|asfg D|dfg|trtyy|errt D|ert|frty|wer Here I need to replace the third column value with 100 of the first record only and while printing I need to print the full file content also..I am expecting a result like this H|123|100|567|asfg D|dfg|trtyy|errt... (3 Replies)
Discussion started by: saj
3 Replies

10. Shell Programming and Scripting

Mathematical Operations on Column

Hi All, I want to perform a mathematical operation on column. Can anyone please help? Here is the sample of operation to be performed: 123 996 100 123 996 200 123 996 200 2015-09-21 123 996 100 123 996 200 123 996 100 What I want is to multiple all values of column # 3 by 100 and... (3 Replies)
Discussion started by: Zaib
3 Replies
Vend::Ship::Postal(3pm) 				User Contributed Perl Documentation				   Vend::Ship::Postal(3pm)

NAME
Vend::Ship::Postal -- Calculate US Postal service international rates SYNOPSIS
(in catalog.cfg) Database usps ship/usps.txt TAB Database air_pp ship/air_pp.txt TAB Database surf_pp ship/surf_pp.txt TAB (in shipping.asc) air_pp: US Postal Air Parcel crit weight min 0 max 0 cost e No shipping needed! at_least 4 adder 1 aggregate 70 table air_pp min 0 max 1000 cost s Postal min 70 max 9999999 cost e Too heavy for Air Parcel surf_pp: US Postal Surface Parcel crit weight min 0 max 0 cost e No shipping needed! at_least 4 adder 1 aggregate 70 table surf_pp min 0 max 1000 cost s Postal min 70 max 9999999 cost e Too heavy for Postal Parcel DESCRIPTION
Looks up a service zone by country in the "usps" table, then looks in the appropriate rate table for a price by that zone. Can aggregate shipments greater than 70 pounds by assuming you will ship multiple 70-pound packages (plus one package with the remainder). perl v5.14.2 2010-03-25 Vend::Ship::Postal(3pm)
All times are GMT -4. The time now is 05:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy