Connecting Tech Pros Worldwide Help | Site Map

(standard_in) 1: parse error

Newbie
 
Join Date: Oct 2006
Posts: 7
#1: Dec 13 '06
Expand|Select|Wrap|Line Numbers
  1. #!/bin/bash
  2. #sar.sh
  3. i=1
  4. while read myline
  5. do
  6.     if [ $i -eq 1 ]
  7.     then
  8.         echo "Report Date: $(cut -d" " -f4 ornek2-c.txt)" > output.txt
  9.     elif [ $i -gt 3 ]
  10.     then
  11.         echo $myline > temp.txt
  12.         proc=$(cut -d" " -f3 temp.txt)
  13.         echo $proc > temp.txt
  14.         cat temp.txt >> temp2.txt
  15.     fi
  16.     i=$(expr $i + 1)
  17. done <ornek2-c.txt
  18.  
  19. index=$(expr $i - 4)
  20.  
  21. cat temp2.txt | awk '{ sum+=$1 } END {print sum}'
  22. average=$(echo "scale=4; $sum/$index"|bc)
  23. echo $average
  24. exit 0
  25.  
ornek2-c.txt: http://www.rafb.net/paste/results/xKMpYT30.html

the output after execution(./sar.sh):

144
42.91
(standard_in) 1: parse error

i created ornek2-c.txt file with "sar -c -f ornek2.sa > ornek2-c.txt" command.i'm trying to find the average value of the proc/s column in ornek2-c.txt.

Thanks in advance.
Newbie
 
Join Date: Oct 2006
Posts: 7
#2: Dec 13 '06

re: (standard_in) 1: parse error


Quote:

Originally Posted by hta1984

Expand|Select|Wrap|Line Numbers
  1. cat temp2.txt | awk '{ sum+=$1 } END {print sum}'
  2. average=$(echo "scale=4; $sum/$index"|bc)
  3.  

Expand|Select|Wrap|Line Numbers
  1. sum=$( cat temp2.txt | awk '{ sum+=$1 } END {print sum}' )
  2. average=$(echo "scale=4; $sum/$index" | bc)
  3.  
editing two lines as above solved the problem.
Reply