Sponsored Content
Top Forums Shell Programming and Scripting Finding Maximum value in a column Post 302439978 by jaysean on Sunday 25th of July 2010 11:31:57 AM
Old 07-25-2010
Thanks Christoph, I think that your method will work for me. But there is a slight problem, unlike the sample input that I have given in the above example, the columns are actually tab separated. Also the third column can have spaces in some cases. The script fails in those cases. Can you please suggest a fix?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix shell script for finding top ten files of maximum size

I need to write a Unix shell script which will list top 10 files in a directory tree on basis of size. i.e. first file should be the biggest in the whole directory and all its sub directories. Please suggest any ideas (10 Replies)
Discussion started by: abhilashnair
10 Replies

2. Shell Programming and Scripting

for each different entry in column 1 extract maximum values from column 2 in unix/awk

Hello, I have 2 columns (1st column has multiple entries but the corresponding values in the column 2 may be the same or different.) however I want to extract unique values for each entry in column 1 by assigning the max value from column 2 SDF4 -0.211654 SDF4 0.978068 ... (1 Reply)
Discussion started by: Diya123
1 Replies

3. Homework & Coursework Questions

Find the Maximum value and average of a column

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to complete a script which will allow me to find: a) reads a value from the keyboard. (ask the... (4 Replies)
Discussion started by: dstewie
4 Replies

4. Shell Programming and Scripting

Maximum of a column

Hi, I have a file like this a 1 2 a 5 8 a 66 100 b 1 2 b 2 3 b 111 143 d 4 5 d 4 6 e 77 727 g 7 8 How can I extract the maximum of col3 respective to col1. I meant, the output will be a 100 b 143 d 6 (1 Reply)
Discussion started by: jacobs.smith
1 Replies

5. Shell Programming and Scripting

Finding minimum maximum and average

I am trying to find the minimum maximum and average from one file which has values Received message from https://www.demandmatrix.net/app/dm/xml] in milliseconds. Received message from https://www.demandmatrix.net/app/dm/xml] in milliseconds. Received message from... (5 Replies)
Discussion started by: aroragaurav.84
5 Replies

6. Answers to Frequently Asked Questions

Finding maximum occurrence value using awk

Hi everyone, I'm a new member at the forum I have a file like this: field 2 values are either 0 or negative. file test4: 100815 -20 118125 0 143616 0 154488 0 154488 0 154488 -6 196492 -5 196492 -9 196492 -7 27332 0 29397 0 I would like to print a... (1 Reply)
Discussion started by: meet77
1 Replies

7. UNIX for Dummies Questions & Answers

Finding maximum occurrence value using awk

Hi everyone, I'm a new member at the forum I mistakenly posted this elsewhere too. I have a file like this: field 2 values are either 0 or negative. file test4: 100815 -20 118125 0 143616 0 154488 0 154488 0 154488 -6 196492 -5 196492 -9 196492 -7 27332 0... (5 Replies)
Discussion started by: meet77
5 Replies

8. Shell Programming and Scripting

Finding the maximum timestamp in a folder

I've the files in a directory in the following format having date +%Y%m%d%H YR_MNTH_2013061205 YR_MNTH_2013060107 and i need the latest file i.e; YR_MNTH_2013061205 to be moved to another folder #!/bin/ksh # Ksh 88 Version for test_time in YR* do --- done How can i achieve that !... (2 Replies)
Discussion started by: smile689
2 Replies

9. Shell Programming and Scripting

Get maximum per column from CSV file, based on date column

Hello everyone, I am using ksh on Solaris 10 and I'm gathering data in a CSV file that looks like this: 20170628-23:25:01,1,0,0,1,1,1,1,55,55,1 20170628-23:30:01,1,0,0,1,1,1,1,56,56,1 20170628-23:35:00,1,0,0,1,1,2,1,57,57,2 20170628-23:40:00,1,0,0,1,1,1,1,58,58,2... (6 Replies)
Discussion started by: ejianu
6 Replies

10. Shell Programming and Scripting

awk to find maximum and minimum from column and store in other column

Need your support for below. Please help to get required output If column 5 is INV then only consider column1 and take out duplicates/identical rows/values from column1 and then put minimum value of column6 in column7 and put maximum value in column 8 and then need to do subtract values of... (7 Replies)
Discussion started by: as7951
7 Replies
pr(1)							      General Commands Manual							     pr(1)

NAME
pr - print files SYNOPSIS
[options] [files] DESCRIPTION
The command prints the named files on the standard output. If file is or if no files are specified, the standard input is assumed. By default, the listing is separated into pages, each headed by the page number, a date and time, and the name of the file. By default, columns are of equal width, separated by at least one space; lines that do not fit are truncated. If the option is used, lines are not truncated and columns are separated by the separation character. If the standard output is associated with a terminal, error messages are withheld until has completed printing. Options The following options can be used singly or combined in any order: Begin printing with page k (default is 1). Produce k-column output (default is 1). This option should not be used with The options and are assumed for multi-column output. Produce k-column output, same as Print multi-column output across the page. This option is appropriate only with the option. Merge and print all files simultaneously, one per column (overrides the and options). Double space the output. Expand input tabs to character positions k+1, 2xk+1, 3xk+1, etc. If k is 0 or is omitted, default tab settings at every eighth position are assumed. Tab characters in the input are expanded into the appropriate number of spaces. If c (any nondigit character) is given, it is treated as the input tab character (default for c is the tab character). In output, replace white space wherever possible by inserting tabs to character positions k+1, 2xk+1, 3xk+1, etc. If k is 0 or is omitted, default tab settings at every eighth position are assumed. If c (any nondigit character) is given, it is treated as the output tab character (default for c is the tab character). Provide k-digit line numbering (default for k is 5). The number occupies the first k+1 character positions of each column of nor- mal output or each line of output. If c (any nondigit character) is given, it is appended to the line number to separate it from whatever follows (default for c is a tab). Set the width of a line to k character positions (default is 72 for equal-width, multi-column output; no limit otherwise). Width specifications are only effective for multi-columnar output. Offset each line by k character positions (default is 0). The number of character positions per line is the sum of the width and offset. Set the length of a page to k lines (default is 66). If k is less than what is needed for the page header and trailer, the option is in effect; that is, header and trailer lines are suppressed in order to make room for text. Use the next argument as the header to be printed instead of the file name. Pause before beginning each page if the output is directed to a terminal rings the bell at the terminal and waits for a Return). Use form-feed character for new pages (default is to use a sequence of line-feeds). Pause before beginning the first page if the standard output is associated with a terminal. Same as Provided for backwards compatibility. Print no diagnostic reports on failure to open files. Print neither the five-line identifying header nor the five-line trailer normally supplied for each page. Quit printing after the last line of each file without spacing to the end of the page. Separate columns by the single character c instead of by the appropriate number of spaces (default for c is a tab). EXTERNAL INFLUENCES
Environment Variables determines the interpretation of text and the arguments associated with the and options as single-byte and/or multi-byte characters. determines the format and contents of date and time strings. determines the language in which messages are displayed. If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to See envi- ron(5). International Code Set Support Single-byte and multi-byte character code sets are supported. RETURN VALUE
The returns the following values upon completion: Successful completion. One or more of the input files do not exist or cannot be opened. EXAMPLES
Print and as a double spaced, three column listing headed by ``file list'': Write on expanding tabs to columns 10, 19, 28, 37, ... : Print in default format with nonblank lines numbered down the left side: FILES
SEE ALSO cat(1), lp(1), nl(1), ul(1). STANDARDS CONFORMANCE
pr(1)
All times are GMT -4. The time now is 10:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy