The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-13-2006
kekanap's Avatar
kekanap kekanap is offline
Registered User
  
 

Join Date: Sep 2003
Location: South Africa
Posts: 36
to do with awk

Hallo All, this is my code below. The problem happens under section A because field $9 sometimes does not contain a number it contains a ( and a number is contained in field $10 as result under sectionC we get a syntax error @
echo "scale=1; $aa+$ee+$ff"|bc > /tmp/pax/c3.txt

So i need to choose field $9 but if there is no number then I need to choose field $10. Please help.




#!/usr/bin/ksh
#
#Author: Paxley Kekana 01-Nov-2006
#
set -x
#
export NOW=`date +"%Y%m%d_%T"`
#
echo $NOW
#
cd /var/opt/SURGE/logs
ll -ltr som*|tail -1 > /tmp/pax/a.txt
awk '{print $9}' /tmp/pax/a.txt > /tmp/pax/b.txt
#
dd=$(</tmp/pax/b.txt)
#
grep "Interval No. SURs/Sec =" $dd | tail -1 > /tmp/pax/c.txt
awk '{print $10}' /tmp/pax/c.txt > /tmp/pax/d.txt
#
ee=$(</tmp/pax/d.txt)
#
#====================A====A===============================#
#
cd ../../DataBroker/logs
ll -ltr sdb.log*|tail -1 > /tmp/pax/a1.txt
awk '{print $9}' /tmp/pax/a1.txt > /tmp/pax/b1.txt
#
ss=$(</tmp/pax/b1.txt)
#

grep "Output Rate :" $ss | tail -1 > /tmp/pax/c1.txt
awk '{print $9}' /tmp/pax/c1.txt > /tmp/pax/d1.txt
#
ff=$(</tmp/pax/d1.txt)
#
#=====================B=====B===============================#
#
ll -ltr sdb_*.log* |tail -1 > /tmp/pax/a2.txt
awk '{print $9}' /tmp/pax/a2.txt > /tmp/pax/b2.txt
#
gg=$(</tmp/pax/b2.txt)
#
grep "Output Rate" $gg |tail -1 > /tmp/pax/c2.txt
awk '{print $9}' /tmp/pax/c2.txt > /tmp/pax/d2.txt
#
aa=$(</tmp/pax/d2.txt)
#
#======================C=====C===========================
echo
echo
#
#((zz=$ee+$ff+$aa))
#
#echo $zz
echo "scale=1; $aa+$ee+$ff"|bc > /tmp/pax/c3.txt
#
zz=$(</tmp/pax/c3.txt)
echo $zz > /tmp/pax/$NOW.txt

#---------------END-----------------------------------------------#
  #2 (permalink)  
Old 11-13-2006
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
forum rule #4 prohibits cross-posting ... it's a good rule to follow ...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:38 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0