need help generating this output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help generating this output
# 1  
Old 07-08-2010
need help generating this output

need to check hardware error are zero

Code:
iostat -en |awk '{ if ( $2 == 0 ) { print "      " }  else { print " Hardware errors "} }

can someone please tell me whats wrong with this

---------- Post updated at 10:19 PM ---------- Previous update was at 10:16 PM ----------

Code:
iostat -en
  ---- errors ---
  s/w h/w trn tot device
    2   0   0   2 c1t0d0
    3   0   0   3 c0t0d0
    2   0   0   2 c1t2d0
    0   0   0   0 c4t600A0B80005A4D130000039F4A4689B8d0
    0   0   0   0 c4t600A0B80005A4D15000003954A468A59d0
    2   0   0   2 c4t600A0B80005A4D13000003A14A468B24d0
    2   0   0   2 c4t600A0B80005A4D15000003964A468BE9d0
    2   0   0   2 c4t600A0B80005A4D13000003A24A468C64d0
    2   0   0   2 c4t600A0B80005A4D15000003974A468E29d0
    2   0   0   2 c4t600A0B80005A4D13000003A34A468EDCd0
    0   0   0   0 c4t600A0B80005A4D15000003994A468F7Fd0


Last edited by Scott; 07-28-2010 at 04:40 AM.. Reason: Code tags
# 2  
Old 07-08-2010
Hi,

there is a single quote missing at the end of your command.
Try:

Code:
iostat -en | awk '/^[0-9]/{if ($2 != 0 ) print "Hardware errors"}'

HTH Chris
# 3  
Old 07-08-2010
i need to print errors instead of the hardware errors can someone help
# 4  
Old 09-17-2010
hi its not working it doesnot generate any ouput can u help

sh: iostat: cannot execute

Last edited by arch12; 09-17-2010 at 02:07 AM..
# 5  
Old 09-17-2010
Code:
iostat -en  |awk '{print $0, ($2)?X:"Hardware errors"}'

If the iostat output like this:

Code:
iostat -en
  ---- errors ---
  s/w h/w trn tot device
    2   0   0   2 c1t0d0
    3   0   0   3 c0t0d0
    2   0   0   2 c1t2d0
    0   0   0   0 c4t600A0B80005A4D130000039F4A4689B8d0
    0   0   0   0 c4t600A0B80005A4D15000003954A468A59d0
    2   0   0   2 c4t600A0B80005A4D13000003A14A468B24d0
    2   123   0   2 c4t600A0B80005A4D15000003964A468BE9d0
    2   234   0   2 c4t600A0B80005A4D13000003A24A468C64d0
    2   0   0   2 c4t600A0B80005A4D15000003974A468E29d0
    2   0   0   2 c4t600A0B80005A4D13000003A34A468EDCd0
    0   0   0   0 c4t600A0B80005A4D15000003994A468F7Fd0

the awk ouput is:


Code:
  ---- errors ---
  s/w h/w trn tot device
    2   0   0   2 c1t0d0 Hardware errors
    3   0   0   3 c0t0d0 Hardware errors
    2   0   0   2 c1t2d0 Hardware errors
    0   0   0   0 c4t600A0B80005A4D130000039F4A4689B8d0 Hardware errors
    0   0   0   0 c4t600A0B80005A4D15000003954A468A59d0 Hardware errors
    2   0   0   2 c4t600A0B80005A4D13000003A14A468B24d0 Hardware errors
    2   123   0   2 c4t600A0B80005A4D15000003964A468BE9d0
    2   234   0   2 c4t600A0B80005A4D13000003A24A468C64d0
    2   0   0   2 c4t600A0B80005A4D15000003974A468E29d0 Hardware errors
    2   0   0   2 c4t600A0B80005A4D13000003A34A468EDCd0 Hardware errors
    0   0   0   0 c4t600A0B80005A4D15000003994A468F7Fd0 Hardware errors

# 6  
Old 09-17-2010
nope i just want to check only if $2 is zero.print just the h/w errors

Code:
iostat -en |awk '{ if ( $2 == 0 ) { print "      " }  else { print " Hardware errors "} }


Last edited by Franklin52; 09-17-2010 at 09:18 AM.. Reason: Please use code tags!
# 7  
Old 09-17-2010
Code:
 iostat -en | awk '{print ($2)?"Hardware errors":X}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generating histogram

Hi, I have 2 files with similar structure - reference and test that I would like to BIN both and generate the comparison. input files structure is: a 3 b 10 c 3 d 7 e 1 f 4 g 9 h 6 I would like the output to be (lets say both reference and test are the file above - no diff) BIN ... (3 Replies)
Discussion started by: yan1
3 Replies

2. UNIX for Beginners Questions & Answers

Split Command Generating Incomplete Output Files

Hello All, May i please know how do i ensure my split command would NOT generate incomplete output files like below, the last lines in each file is missing some columns or last line is complete. split -b 50GB File File_ File_aa |551|70210203|xxxxxxx|12/22/2010 20:44:58|11/01/2010... (1 Reply)
Discussion started by: Ariean
1 Replies

3. Shell Programming and Scripting

Generating password

Hi, I am new to shell scripting, my requirement is I have to generate password for Users automatically using script and it should send on mail on that particular date using crontab. how to do this? (1 Reply)
Discussion started by: manoj.solaris
1 Replies

4. Shell Programming and Scripting

Randomly selecting sequences and generating specific output files

I have two files containing hundreds of different sequences with the same Identifiers (ID-001, ID-002, etc.,), something like this: Infile1: ID-001 ATGGGAGCGGGGGCGTCTGCCTTGAGGGGAGAGAAGCTAGATACA ID-002 ATGGGAGCGGGGGCGTCTGTTTTGAGGGGAGAGAAGCTAGATACA ID-003... (18 Replies)
Discussion started by: Xterra
18 Replies

5. Shell Programming and Scripting

Help with generating a script

I am a biologist who is new to linux and am having difficulty generating a script to do what I want it to do! I have tried basic grep commands, but even that does not give me back the data I want. I have many files that are all currently in .xslx and I'm not sure if they need to be .csv or .txt... (16 Replies)
Discussion started by: kellywilliams
16 Replies

6. Web Development

Detecting browser locales/languages and generating output

We have a Java app that renders Localized text on user's browser session based upon browser language settings. The app reads the browser language settings and prepares the localized text. But recently we faced issues for Mozilla 5.0 version browser. Note our code works fine in IE. Taking an... (1 Reply)
Discussion started by: uunniixx
1 Replies

7. Shell Programming and Scripting

awk not generating the expected output

Hi, I am presently stuck in a csv file. INPUT CSV baseball,NULL,8798765,Most played baseball,NULL,8928192,Most played baseball,NULL,5678945,Most played cricket,NOTNULL,125782,Usually played cricket,NOTNULL,678921,Usually played EXPECTED OUTPUT CSV ... (7 Replies)
Discussion started by: scripter12
7 Replies

8. Shell Programming and Scripting

Generating Combinations

Hi, I need to generate all combinations upto n-1 level, if the input file looks like say, A B C D . . .... I need to generate all combinations such that first value remains constant and the remaning are combined with all possible ways. Output A AB AC AD ABC (1 Reply)
Discussion started by: zorg4u
1 Replies

9. AIX

Generating a Subsystem

Hello, I'm trying to generate a subsystem which supports startsrc, stopsrc and refresh I want to specify special arguments in case of stopsrc and refresh for example: startsrc: /bin/testscript start stopsrc: /bin/testscript stop refresh: /bin/testscript restart which should be... (0 Replies)
Discussion started by: funksen
0 Replies

10. Programming

generating timer

I'm trying generate an interrupt every 1 seconds using itimer and My clock is not running. This is what i did : printf("about to sleep for 1 second \n"); signal(SIGALRM, wakeup); //myTimer.it_interval.tv_sec=0; //myTimer.it_interval.tv_usec =0; ... (5 Replies)
Discussion started by: Confuse
5 Replies
Login or Register to Ask a Question