Sponsored Content
Top Forums Shell Programming and Scripting To get max/min Date/Timestamp from a file Post 302530772 by kumaran_5555 on Wednesday 15th of June 2011 02:47:38 AM
Old 06-15-2011
This code should work for you

If your seperator is pipe instead of comma use replace the dot with pipe inside -F"[-,:. ]"

Code:
awk -F"[-,:. ]" '

BEGIN{
min_date="99999999"
min_ext="99999999999999999999"

}
{
date=$2$3$4; ext=$5$6$7$8$9$10$11; 
if(min_date>date){min_date=date}; 
if(max_date<date){max_date=date};
if(min_ext>ext){min_ext=ext}
if(max_ext<ext){max_ext=ext}
}


END{

print "min date "min_date
print "max date " max_date
print "min ext "min_ext
print "max ext "max_ext
}' test.txt

Your sample file isn't matching the initial sample given here. may be few changes has to be done.

Last edited by kumaran_5555; 06-15-2011 at 04:11 AM..
This User Gave Thanks to kumaran_5555 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

min and max value of process id

We are running a AIX 5.2 OS. Would anyone happen to know what the max value for a process id could be? Thanks jerardfjay :) (0 Replies)
Discussion started by: jerardfjay
0 Replies

2. Shell Programming and Scripting

how to find min, max dates in a file

hello friends...:-) i need some help i have a file cantain like this Star1 ,NetWork,09/02/2008 Star1 ,NetWork,10/02/2008 Star1 ,NetWork,11/02/2008 Star2 ,NetWork,08/03/2008 Star2 ,NetWork,09/04/2008 Star2 ,NetWork,10/05/2008 i need to find out min, max dates the output look like... (6 Replies)
Discussion started by: gemini106
6 Replies

3. Shell Programming and Scripting

get min, max and average value

hi! i have a file like the attachement. I'd like to get for each line the min, max and average values. (there is 255 values for each line) how can i get that ? i try this, is it right? BEGIN {FS = ","; OFS = ";";max=0;min=0;moy=0;total=0;freq=890} $0 !~ /Trace1:/ { ... (1 Reply)
Discussion started by: riderman
1 Replies

4. Shell Programming and Scripting

Check if a date field has date or timestamp or date&timestamp

Hi, In a field, I should receive the date with time stamp in a particular field. But sometimes the vendor sends just the date or the timestamp or correctl the date&timestamp. I have to figure out the the data is a date or time stamp or date&timestamp. If it is date then append "<space>00:00:00"... (1 Reply)
Discussion started by: machomaddy
1 Replies

5. Shell Programming and Scripting

Converting a date to friday date and finding Min/Max date

Dear all, I have 2 questions. I have a file with many rows which has date of the format YYYYMMDD. 1. I need to change the date to that weeks friday date(Ex: 20120716(monday) to 20120720). Satuday/Sunday has to be changed to next week friday date too. 2. After converting the date to... (10 Replies)
Discussion started by: 2001.arun
10 Replies

6. Homework & Coursework Questions

Min/Max/counter/while loop from file

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: The program is supposed to read in text from a given file ( different samples provided in the homework but not... (1 Reply)
Discussion started by: c++newb
1 Replies

7. Shell Programming and Scripting

Print min and max value from two column

Dear All, I have data like this, input: 1254 10125 1254 10126 1254 10127 1254 10128 1254 10129 1255 10130 1255 10131 1255 10132 1255 10133 1256 10134 1256 10135 1256 10137... (3 Replies)
Discussion started by: aksin
3 Replies

8. Shell Programming and Scripting

Average, min and max in file with header, using awk

Hi, I have a file which looks like this: FID IID MISS_PHENO N_MISS N_GENO F_MISS 12AB43131 12AB43131 N 17774 906341 0.01961 65HJ87451 65HJ87451 N 10149 906341 0.0112 43JJ21345 43JJ21345 N 2826 906341 0.003118I would... (11 Replies)
Discussion started by: kayakj
11 Replies

9. Shell Programming and Scripting

Get min and max value in column

Gents, I have a big file file like this. 5100010002 5100010004 5100010006 5100010008 5100010010 5100010012 5102010002 5102010004 5102010006 5102010008 5102010010 5102010012 The file is sorted and I would like to find the min and max value, taking in the consideration key1... (3 Replies)
Discussion started by: jiam912
3 Replies

10. Shell Programming and Scripting

Find min and max time taken from a log file

You have a log file as attached in sample input with various operations and time taken by each of them. Write a script to find the min and max time taken for each operation. Sample output is attached. Sample Input is given as below: operation1,83621 operation2,72321 operation3,13288... (1 Reply)
Discussion started by: Chandan_Bose
1 Replies
truchet(6x)							XScreenSaver manual						       truchet(6x)

NAME
truchet - draws curved or angular Truchet patterns SYNOPSIS
truchet [-display host:display.screen] [-foreground color] [-background color] [-window] [-root] [-mono] [-install] [-visual visual] [-delay milliseconds] [-min-width integer] [-min-height integer] [-max-width integer] [-max-height integer] [-max-linewidth integer] [-min- linewidth integer] [-erase] [-no-erase] [-erase-count integer] [-square] [-not-square] [-curves] [-no-curves] [-angle] [-no-angles] [-scroll] [-scroll-overlap integer] [-anim-delay integer] [-anim-step-size integer] [-fps] DESCRIPTION
The truchet program draws arc and line based Truchet patterns. OPTIONS
truchet accepts the following options: -window Draw on a newly-created window. This is the default. -root Draw on the root window. -mono If on a color display, pretend we're on a monochrome display. -install Install a private colormap for the window. -visual visual Specify which visual to use. Legal values are the name of a visual class, or the id number (decimal or hex) of a specific visual. -delay milliseconds How long to wait between drawing each screenful. Default is 1 seconds. -min-width integer The minimum width in pixels of each square. Default is 40. -min-height integer The minimum height in pixels of each square. Default is 40. -max-width integer The maximum width in pixels of each square. Default is 150. -max-height integer The maximum height in pixels of each square. Default is 150. -max-linewidth integer The maximum width of the lines used to draw. Default is 25. -min-linewidth integer The minimum width of the lines used to draw. Default is 2. -erase -no-erase Whether to clear the screen after each screenful is drawn. Default is True (erase). -erase-count integer The number of screenfuls to draw before erasing. Default is 25. -square -not-square Whether to force the tiles to be square. Default is True (square). -curves -no-curves Whether to draw the arc based Truchet pattern. Default is True (curves). -angles -no-angles Whether or not to draw the line based Truchet pattern. Default is True (angles) -scroll Use the scroll mode. Default is False. -scroll-overlap The amount to scroll from one side to another. Default is 400. -anim-delay The time to pause between each animation step. Default is 100. -anim-step-size The amount of steps to skip between each animation step. Default is 3. -fps Display the current frame rate and CPU load. ENVIRONMENT
DISPLAY to get the default host and display number. XENVIRONMENT to get the name of a resource file that overrides the global resources stored in the RESOURCE_MANAGER property. SEE ALSO
X(1), xscreensaver(1) COPYRIGHT
Copyright (C) 1998 by Adrian Likins. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, pro- vided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in sup- porting documentation. AUTHOR
Adrian Likins, 1998. X Version 11 5.15 (28-Sep-2011) truchet(6x)
All times are GMT -4. The time now is 06:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy