Unix Shell - comparision script

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > September 2007 > comparision script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author comparision script
Nikunj Khakhar

2007-09-24, 7:31 am

Hi,



I am working on the Storage related script. i caputred following
sample output :
69
00
13
00
00
00
00
00
00
00
00
02
27

Above output is for the TIME (hour) of the snapshot i want the all
values which Greter than 8 (hours)
how can i compair above value with the 8 ( 00,01,02 values i want to
convert in 1,2,3,4,5,6..) so it can compair by the if statment
and i also want suppose if i have check one conddition than it shuold
not check again mean once it checked by script it should not check
again pl. need experts input..

thanks
nikunj

Vakayil Thobias

2007-09-24, 7:31 am

Nikunj Khakhar wrote:
> Hi,
>
>
>
> I am working on the Storage related script. i caputred following
> sample output :
> 69
> 00
> 13
> 00
> 00
> 00
> 00
> 00
> 00
> 00
> 00
> 02
> 27
>
> Above output is for the TIME (hour) of the snapshot i want the all
> values which Greter than 8 (hours)
> how can i compair above value with the 8 ( 00,01,02 values i want to
> convert in 1,2,3,4,5,6..) so it can compair by the if statment
> and i also want suppose if i have check one conddition than it shuold
> not check again mean once it checked by script it should not check
> again pl. need experts input..
>
> thanks
> nikunj
>


cat filename | awk '$1>08 {print $1}'
Janis

2007-09-24, 7:31 am

On 24 Sep., 13:00, Vakayil Thobias <vakayil.thob...@alcatel-
lucent.com> wrote:
> Nikunj Khakhar wrote:
>
>
>
>
> cat filename | awk '$1>08 {print $1}'


awk '$1>08' filename

(Cats and dogs have other partialities.)

Janis

Ed Morton

2007-09-24, 7:31 am

Janis wrote:
> On 24 Sep., 13:00, Vakayil Thobias <vakayil.thob...@alcatel-
> lucent.com> wrote:
>
>
>
> awk '$1>08' filename


Fore:

awk '$1>8' filename

> (Cats and dogs have other partialities.)
>
> Janis
>

Nikunj Khakhar

2007-09-24, 7:31 am

On Sep 24, 6:52 am, Janis <janis_papanag...@hotmail.com> wrote:
> On 24 Sep., 13:00, Vakayil Thobias <vakayil.thob...@alcatel-
>
>
>
>
>
> lucent.com> wrote:
>
>
>
>
>
> awk '$1>08' filename
>
> (Cats and dogs have other partialities.)
>
> Janis- Hide quoted text -
>
> - Show quoted text -


Thanks alll,

I got this output

1936
69
13
1739
27

than i want the full data for the above value because so how can i
get ?


than i want to

Ed Morton

2007-09-24, 1:26 pm

Nikunj Khakhar wrote:

> On Sep 24, 6:52 am, Janis <janis_papanag...@hotmail.com> wrote:
>
>
>
> Thanks alll,
>
> I got this output
>
> 1936
> 69
> 13
> 1739
> 27


That's impossible given the sample input you posted.

> than i want the full data for the above value because so how can i
> get ?


Show us your real sample input and expected output.

Ed.
Nikunj Khakhar

2007-09-24, 1:26 pm

On Sep 24, 7:31 am, Ed Morton <mor...@lsupcaemnt.com> wrote:
> Nikunj Khakhar wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> That's impossible given the sample input you posted.
>
>
> Show us your real sample input and expected output.
>
> Ed.- Hide quoted text -
>
> - Show quoted text -

$ cat snap_scr| grep -v Broken-off | grep -v Lag | awk '{print $4}' |
cut -f1 -d: |awk '$1>08'

1936

69

13

1739

27

27

I want to list the all fileds of the above value

Janis

2007-09-24, 1:26 pm

On 24 Sep., 14:45, Nikunj Khakhar <nikunj.khak...@gmail.com> wrote:
> On Sep 24, 7:31 am, Ed Morton <mor...@lsupcaemnt.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> $ cat snap_scr| grep -v Broken-off | grep -v Lag | awk '{print $4}' |
> cut -f1 -d: |awk '$1>08'
>
> 1936
>
> 69
>
> 13
>
> 1739
>
> 27
>
> 27
>
> I want to list the all fileds of the above value


It's not clear what you want. Please try to rephrase your task and
provide real sample input and expected output.

For now, whatever you need, you will be more flexible to re-write your
above command pipe...

> $ cat snap_scr| grep -v Broken-off | grep -v Lag | awk '{print $4}' |
> cut -f1 -d: |awk '$1>08'


....with awk...

awk '!/Broken-off/ && !/Lag/ { split($4,f,":"); if (f[1]>8) print }'
snap_scr

The above (untested!) will print the complete matching lines. If you
want specific fields use, e.g. for the fourth field, print $4 instead
of print.

Janis

Kenny McCormack

2007-09-24, 1:26 pm

In article <1190638960.331736.27390@g4g2000hsf.googlegroups.com>,
Janis <janis_papanagnou@hotmail.com> wrote:
....
>...with awk...
>
>awk '!/Broken-off/ && !/Lag/ { split($4,f,":"); if (f[1]>8) print }'
>snap_scr


!/Broken-off|Lag/ && split($4,f,":") && f[1]>8

Nikunj Khakhar

2007-09-24, 1:26 pm

On Sep 24, 8:34 am, gaze...@xmission.xmission.com (Kenny McCormack)
wrote:
> In article <1190638960.331736.27...@g4g2000hsf.googlegroups.com>,Janis <janis_papanag...@hotmail.com> wrote:
>
> ...
>
>
>
> !/Broken-off|Lag/ && split($4,f,":") && f[1]>8


Thanks all,

i got what i wanted i got o/p

usspna05a:/vol/usspbwp01Data01_na05a/san usspna06:/vol/
usspbwp01Data01/san_desta Source 69:16:50 Idle
usspna05a:/vol/usspbwp01Misc01_na05a/san usspna06:/vol/
usspbwp01Misc01/san_desta Source 13:20:54 Idle
usspna05a:saptranstest
usspna06:saptranstest Source
1739:39:54 Idle
usspna05a:/vol/usspbwp01Logs01_na05a/san uswdna01a:/vol/
usspbwp01Logs01_na05a/sandest Source 27:05:10 Transferring

i got using command : cat snap_scr | awk '!/Broken-off/ && !/Lag/
{ split($4,f,":"); if (f[1]>8) print }'



now i tried to capture second part i want minute part for example
69:16 in 4th column i wanted to capture minute "16" and compair only
if minute is gt than 10 than it should list all data with greter than
10 i tried to change in below command

cat snap_scr | awk '!/Broken-off/ && !/Lag/ { split($4,f,":"); if
(f[2]>10) print }'

but not working ... any suggestion.. plz././

Ed Morton

2007-09-24, 1:26 pm

Nikunj Khakhar wrote:
> On Sep 24, 8:34 am, gaze...@xmission.xmission.com (Kenny McCormack)
> wrote:
>
>
>
> Thanks all,
>
> i got what i wanted i got o/p
>
> usspna05a:/vol/usspbwp01Data01_na05a/san usspna06:/vol/
> usspbwp01Data01/san_desta Source 69:16:50 Idle
> usspna05a:/vol/usspbwp01Misc01_na05a/san usspna06:/vol/
> usspbwp01Misc01/san_desta Source 13:20:54 Idle
> usspna05a:saptranstest
> usspna06:saptranstest Source
> 1739:39:54 Idle
> usspna05a:/vol/usspbwp01Logs01_na05a/san uswdna01a:/vol/
> usspbwp01Logs01_na05a/sandest Source 27:05:10 Transferring
>
> i got using command : cat snap_scr | awk '!/Broken-off/ && !/Lag/
> { split($4,f,":"); if (f[1]>8) print }'
>
>
>
> now i tried to capture second part i want minute part for example
> 69:16 in 4th column i wanted to capture minute "16" and compair only
> if minute is gt than 10 than it should list all data with greter than
> 10 i tried to change in below command
>
> cat snap_scr | awk '!/Broken-off/ && !/Lag/ { split($4,f,":"); if
> (f[2]>10) print }'
>
> but not working ... any suggestion.. plz././
>


Yes - tell us in what way it's "not working" and, again, show some
sample input and expected output. And get rid of the UUOC:

Bad: cat file | awk '...'
Good: awk '...' file

Regards,

Ed.
Bill Marcum

2007-09-24, 1:26 pm

On Mon, 24 Sep 2007 06:51:07 -0700, Nikunj Khakhar
<nikunj.khakhar@gmail.com> wrote:
>
>
> On Sep 24, 8:34 am, gaze...@xmission.xmission.com (Kenny McCormack)
> wrote:
>
> Thanks all,
>
> i got what i wanted i got o/p
>
> usspna05a:/vol/usspbwp01Data01_na05a/san usspna06:/vol/
> usspbwp01Data01/san_desta Source 69:16:50 Idle
> usspna05a:/vol/usspbwp01Misc01_na05a/san usspna06:/vol/
> usspbwp01Misc01/san_desta Source 13:20:54 Idle
> usspna05a:saptranstest
> usspna06:saptranstest Source
> 1739:39:54 Idle
> usspna05a:/vol/usspbwp01Logs01_na05a/san uswdna01a:/vol/
> usspbwp01Logs01_na05a/sandest Source 27:05:10 Transferring
>
> i got using command : cat snap_scr | awk '!/Broken-off/ && !/Lag/
> { split($4,f,":"); if (f[1]>8) print }'
>

In the data above it looks to me like the time is in $3.



--
* netgod opens his mailbox and immediately wishes he hadnt
Nikunj Khakhar

2007-09-26, 7:31 am

On Sep 24, 9:04 pm, Bill Marcum <marcumb...@bellsouth.net> wrote:
> On Mon, 24 Sep 2007 06:51:07 -0700, Nikunj Khakhar
>
>
>
> <nikunj.khak...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
> In the data above it looks to me like the time is in $3.
>
> --
> * netgod opens his mailbox and immediately wishes he hadnt- Hide quoted text -
>
> - Show quoted text -


hello everyOne Thanks for the give me the good solution of my problem

I have one more query

I have three data
DATA,MISC and LOGS

by if...else i can compair the single value like

if [$DATA = 0]
else
do it
then
don do
fi

How can i use 3 variable using single if statmen which can compair if
value is zero or not ...

with regards,
nikunj

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com