Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Maximum of the values from the output a query Post 302933483 by RavinderSingh13 on Friday 30th of January 2015 04:40:54 AM
Old 01-30-2015
Hello Devendra,

Could you please try following and let me know if this helps you.
Code:
awk '{for(i=1;i<=NF;i++){if(i%2==0){A[j]=A[j]>$i?A[j]:$i} if(i%2!=0){j=$i}}} END{for(u in A){print u OFS A[u]}}'  Input_file

Output will be as follows.
Code:
2015-01-29-05-38-04 1
2015-01-29-05-38-02 5
2015-01-29-05-38-03 5

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Searching partial columns and returning maximum as output

Hello, I am just getting starting with awk and wondering if anyone could help with the following problem. I have a large file of data, 50,000 rows x 6 columns. I would like to search in blocks of 500 rows for a maximum value in a specific column and compile an output file that prints the... (0 Replies)
Discussion started by: xb_analysis
0 Replies

2. Shell Programming and Scripting

add the output of a query to a variable to be used in another query

I would like to use the result of a query in another query. How do I redirect/add the output to another variable? $result = odbc_exec($connect, $query); while ($row = odbc_fetch_array($result)) { echo $row,"\n"; } odbc_close($connect); ?> This will output hostnames: host1... (0 Replies)
Discussion started by: hazno
0 Replies

3. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

4. Shell Programming and Scripting

AWK, Perl or Shell? Unique strings and their maximum values from 3 column data file

I have a file containing data like so: 2012-01-02 GREEN 4 2012-01-02 GREEN 6 2012-01-02 GREEN 7 2012-01-02 BLUE 4 2012-01-02 BLUE 3 2012-01-02 GREEN 4 2012-01-02 RED 4 2012-01-02 RED 8 2012-01-02 GREEN 4 2012-01-02 YELLOW 5 2012-01-02 YELLOW 2 I can't always predict what the... (4 Replies)
Discussion started by: rich@ardz
4 Replies

5. Shell Programming and Scripting

Print minimum and maximum values using awk

Can I print the minimum and maximum values of values in first 4 columns ? input 3038669 3038743 3037800 3038400 m101c 3218627 3218709 3217600 3219800 m290 ............. output 3037800 3038743 m101c 3217600 3219800 m290 (2 Replies)
Discussion started by: quincyjones
2 Replies

6. 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

7. Shell Programming and Scripting

Output minimum and maximum values for replicates ID

Hi All I hope that someone could help me! I have an input file like this, with 4 colum(ID, feature1, start, end): a x 1 5 b x 3 10 b x 4 9 b x 5 16 c x 5 9 c x 4 8 And my output file should be like this: a x 1 5 b x 3 16 c x 4 9 What I would like to do is to output for each ID... (2 Replies)
Discussion started by: giuliangiuseppe
2 Replies

8. Shell Programming and Scripting

Find minimum and maximum values based on column with associative array

Hello, I need to find out the minimum and maximum values based on specific column, and then print out the entire row with the max value. Infile.txt: scf6 290173 290416 . + X_047241 T_00113118-1 scf6 290491 290957 . + X_047241 T_00113118-2 scf6 290898 290957 . + X_047241 T_00113119-3 scf6... (2 Replies)
Discussion started by: yifangt
2 Replies

9. UNIX for Beginners Questions & Answers

To extract values after the maximum value in a txt file

Hello, I'm new to scripting and I need to write a bash script. Here is example of file on which I'm working: 0.3092381 0.3262799 0.3425480 0.3578379 0.3719490 0.3846908 0.3958855 0.4053738 0.4130160 0.4186991 0.4223357 ... (1 Reply)
Discussion started by: jeo_fb
1 Replies

10. Shell Programming and Scripting

Extracting values after the maximum value in a txt file

Hello, I'm new to scripting and I need to write a bash script. Here is example of file on which I'm working: 0.3092381 0.3262799 0.3425480 0.3578379 0.3719490 0.3846908 0.3958855 0.4053738 0.4130160 0.4186991 0.4223357 0.4238688 ... (14 Replies)
Discussion started by: jeo_fb
14 Replies
fitsort(1)						      General Commands Manual							fitsort(1)

NAME
fitsort - sort FITS header information from a list of files SYNOPSIS
dfits <FITS files...> | fitsort <FITS keywords...> DESCRIPTION
fitsort extract keyword values from a set of FITS headers and outputs it in an ASCII table format, which is compatible with most data pro- cessing software packages. It shall only be used in combination with the dfits utility. The ASCII output is shown in columns. Columns are aligned with blank characters and also separated by tabulations. Blank alignment allows human readers to visualize the output in a pretty format, tabulations are there for spreadsheet compatibility. If you want to load out fit- sort output into any spreadsheet, specify that fields shall be separated by tabulations and entries separated by linefeeds. Examples : dfits *.fits | fitsort BITPIX NAXIS NAXIS1 NAXIS2 The output would look like: FILE BITPIX NAXIS NAXIS1 NAXIS2 file0001.fits 16 2 128 128 file0002.fits 32 2 512 512 ... ESO specific features in the FITS header are also supported. To get values for 'HIERARCH ESO' keywords, just give the complete names within double quotes. e.g. dfits *.fits | fitsort "HIERARCH ESO INS LENS" Another way of giving HIERARCH ESO keywords is to use the short FITS notation, the above example can be given as: dfits *.fits | fitsort INS.LENS Example: to retrieve the DPR keywords from an ESO FITS header, you would use: dfits *.fits | fitsort To be completed... DPR.CATG DPR.TYPE DPR.TECH This second way of requesting HIERARCH ESO keywords is not only shorter to type, it also avoids typing quotes or double-quotes on the com- mand-line, making it easier to script with fitsort. Notice that the keywords you give on the command-line are case-insensitive. The above line is equivalent to: dfits *.fits | fitsort dpr.catg dpr.type dpr.tech OPTIONS
-d Do not print out the first output line. This option is useful to get only the query results, without the top line (giving all column names). This makes it easy to script fitsort from programs like awk or perl. FILES
Input files to dfits shall all comply with FITS format. fitsort also supports HIERARCH ESO FITS format. SEE ALSO
dfits (1) 25 Jun 2001 fitsort(1)
All times are GMT -4. The time now is 12:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy