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 Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
nfs administrative tasks lombard_c SUN Solaris 1 01-16-2008 07:15 AM
Count if numbers are not repetitive Raynon Shell Programming and Scripting 7 04-25-2007 11:14 PM
Repetitive Tasks: using if..then inside a loop garak Shell Programming and Scripting 2 03-13-2006 07:36 AM
Need help with tasks! RomeO UNIX for Dummies Questions & Answers 1 11-23-2005 06:03 PM
System Administrators Tasks killerserv News, Links, Events and Announcements 0 05-15-2002 09:56 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-17-2005
JairGuerra JairGuerra is offline
Registered User
  
 

Join Date: Nov 2005
Location: Belize
Posts: 3
Question Repetitive Tasks

Could someone tell me how I can simplify the script that follows!!!
I know that there must be a way how to

grep Average from sar01..................
sar02 .......................
sar03.......................
sar04 and output it to its own file.

My intention is to collect data for the whole month and place in an Excel graph, to monitor how my system worked for the month,



grep Average sar01 > Avgrep01.txt
grep Average sar02 > Avgrep02.txt
grep Average sar03 > Avgrep03.txt
grep Average sar04 > Avgrep04.txt
grep Average sar05 > Avgrep05.txt
grep Average sar06 > Avgrep06.txt
grep Average sar07 > Avgrep07.txt
grep Average sar08 > Avgrep08.txt
grep Average sar09 > Avgrep09.txt
grep Average sar10 > Avgrep10.txt
grep Average sar11 > Avgrep11.txt
grep Average sar12 > Avgrep12.txt
grep Average sar13 > Avgrep13.txt
grep Average sar14 > Avgrep14.txt
grep Average sar15 > Avgrep15.txt
grep Average sar16 > Avgrep16.txt
grep Average sar17 > Avgrep17.txt
grep Average sar18 > Avgrep18.txt
grep Average sar19 > Avgrep19.txt
grep Average sar20 > Avgrep20.txt
grep Average sar21 > Avgrep21.txt
grep Average sar22 > Avgrep22.txt
grep Average sar23 > Avgrep23.txt
grep Average sar24 > Avgrep24.txt
grep Average sar25 > Avgrep25.txt
grep Average sar26 > Avgrep26.txt
grep Average sar27 > Avgrep27.txt
grep Average sar28 > Avgrep28.txt
grep Average sar29 > Avgrep29.txt
grep Average sar30 > Avgrep30.txt
grep Average sar31 > Avgrep31.txt


###########

head -1 Avgrep01.txt > Avhead01.txt
head -1 Avgrep02.txt >> Avhead01.txt
head -1 Avgrep03.txt >> Avhead01.txt
head -1 Avgrep04.txt >> Avhead01.txt
head -1 Avgrep05.txt >> Avhead01.txt
head -1 Avgrep06.txt >> Avhead01.txt
head -1 Avgrep07.txt >> Avhead01.txt
head -1 Avgrep08.txt >> Avhead01.txt
head -1 Avgrep09.txt >> Avhead01.txt
head -1 Avgrep10.txt >> Avhead01.txt
head -1 Avgrep11.txt >> Avhead01.txt
head -1 Avgrep12.txt >> Avhead01.txt
head -1 Avgrep13.txt >> Avhead01.txt
head -1 Avgrep14.txt >> Avhead01.txt
head -1 Avgrep15.txt >> Avhead01.txt
head -1 Avgrep16.txt >> Avhead01.txt
head -1 Avgrep17.txt >> Avhead01.txt
head -1 Avgrep18.txt >> Avhead01.txt
head -1 Avgrep19.txt >> Avhead01.txt
head -1 Avgrep20.txt >> Avhead01.txt
head -1 Avgrep21.txt >> Avhead01.txt
head -1 Avgrep22.txt >> Avhead01.txt
head -1 Avgrep23.txt >> Avhead01.txt
head -1 Avgrep24.txt >> Avhead01.txt
head -1 Avgrep25.txt >> Avhead01.txt
head -1 Avgrep26.txt >> Avhead01.txt
head -1 Avgrep26.txt >> Avhead01.txt
head -1 Avgrep27.txt >> Avhead01.txt
head -1 Avgrep28.txt >> Avhead01.txt
head -1 Avgrep29.txt >> Avhead01.txt
head -1 Avgrep30.txt >> Avhead01.txt
head -1 Avgrep31.txt >> Avhead01.txt


###########


sed '/^$/d' Avhead01.txt | nawk -F " " '{print $2,$3,$4,$5}' > sarcpu_btl-main.txt

###########




head -12 Avgrep01.txt | tail -1 > Avhead02.txt
head -12 Avgrep02.txt | tail -1 >> Avhead02.txt
head -12 Avgrep03.txt | tail -1 >> Avhead02.txt
head -12 Avgrep04.txt | tail -1 >> Avhead02.txt
head -12 Avgrep05.txt | tail -1 >> Avhead02.txt
head -12 Avgrep06.txt | tail -1 >> Avhead02.txt
head -12 Avgrep07.txt | tail -1 >> Avhead02.txt
head -12 Avgrep08.txt | tail -1 >> Avhead02.txt
head -12 Avgrep09.txt | tail -1 >> Avhead02.txt
head -12 Avgrep10.txt | tail -1 >> Avhead02.txt
head -12 Avgrep11.txt | tail -1 >> Avhead02.txt
head -12 Avgrep12.txt | tail -1 >> Avhead02.txt
head -12 Avgrep13.txt | tail -1 >> Avhead02.txt
head -12 Avgrep14.txt | tail -1 >> Avhead02.txt
head -12 Avgrep15.txt | tail -1 >> Avhead02.txt
head -12 Avgrep16.txt | tail -1 >> Avhead02.txt
head -12 Avgrep17.txt | tail -1 >> Avhead02.txt
head -12 Avgrep18.txt | tail -1 >> Avhead02.txt
head -12 Avgrep19.txt | tail -1 >> Avhead02.txt
head -12 Avgrep20.txt | tail -1 >> Avhead02.txt
head -12 Avgrep21.txt | tail -1 >> Avhead02.txt
head -12 Avgrep22.txt | tail -1 >> Avhead02.txt
head -12 Avgrep23.txt | tail -1 >> Avhead02.txt
head -12 Avgrep24.txt | tail -1 >> Avhead02.txt
head -12 Avgrep25.txt | tail -1 >> Avhead02.txt
head -12 Avgrep26.txt | tail -1 >> Avhead02.txt
head -12 Avgrep27.txt | tail -1 >> Avhead02.txt
head -12 Avgrep28.txt | tail -1 >> Avhead02.txt
head -12 Avgrep29.txt | tail -1 >> Avhead02.txt
head -12 Avgrep30.txt | tail -1 >> Avhead02.txt
head -12 Avgrep31.txt | tail -1 >> Avhead02.txt


##########

sed '/^$/d' Avhead02.txt | nawk -F " " '{print $2,$3}' > sarmem_btl-main.txt


##########



rm Av*.txt
  #2 (permalink)  
Old 11-18-2005
vino's Avatar
vino vino is online now Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Try this.

Code:
#! /bin/ksh

typeset -ZR2 day=1

while (($day <= 31))
do
grep Average sar${day} > Avgrep${day}.txt
day=$(($day+1))
done

sed '/^$/d' Avhead01.txt | nawk -F " " '{print $2,$3,$4,$5}' > sarcpu_btl-main.txt

day=1
while (($day <= 31))
do
head -1 Avgrep${day}.txt >> Avhead01.txt
sed -n -e '12p' Avgrep${day}.txt >> Avhead02.txt
day=$(($day+1))
done

sed '/^$/d' Avhead02.txt | nawk -F " " '{print $2,$3}' > sarmem_btl-main.txt

rm -f Av*.txt
Not tested.

Vino
  #3 (permalink)  
Old 11-18-2005
JairGuerra JairGuerra is offline
Registered User
  
 

Join Date: Nov 2005
Location: Belize
Posts: 3
Repetitive Tasks

Will try and inform if works,

Thanks for your time

Jair
  #4 (permalink)  
Old 11-18-2005
JairGuerra JairGuerra is offline
Registered User
  
 

Join Date: Nov 2005
Location: Belize
Posts: 3
Repetitive Tasks

Thanks man,

I modified it just a little because it was not finding Avhead01.
It was just the position of the sed request.

I then added a couple ftp commands to my laptop.

Grateful,

Jair
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 12:45 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