Clear Case, Awk and script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Clear Case, Awk and script
# 1  
Old 10-30-2007
Clear Case, Awk and script

Hello. I should have asked this awhile ago but here is my situation. My task is to generate LOC for different directories. I have a text file that has dates in this format (01-Aug-2006). My task is to read each line and compare it to a branch date. Depending on the date, it should generate a particular config_spec. Once that is done, another script loads the config_specs one by one and performs LOC counts. Here is the first step:

Code:


#!/bin/ksh

#THE OBJECTIVE OF THIS SCRIPT TO READ IN A TEXT FILE THAT #CONTATINS DATES IN A DD-MMM-YYYY FORMAT. EACH LINE IS READ AND #THE DATES ARE COMPARED TO A BENCHMARK DATE. DEPENDING ON THE #DATE, A CONFIG SPEC IS CREATED AND THAT CONFIG SPEC IS USED 
#BY ANOTHER SCRIPT TO PRODUCE THE METRICS OF PROGRAM CODE ON THE SYSTEM.

#NOW, WE OPEN THE TEXT FILE
exec 3<week_ending_dates.txt		

#HERE BEGINS A WHILE LOOP. AS THE FILE IS BEING READ LINE BY LINE, #EACH DATE IS READ AND THEN THE DATE IS TRUNCATED INTO THREE #VARIABLES. NEXT, THE VARIABLE, MONTH, IS TESTED AND SET TO A #NUMERICAL VALUE. 

	while read -u3 LINE 
	do			
		day=$(echo $LINE | cut -d'-' -f1)
		month=$(echo $LINE | cut -d'-' -f2)
		year=$(echo $LINE | cut -d'-' -f3)

		case $month in
		Jan*)month=01;;
		Feb*)month=02;;
		Mar*)month=03;;
		Apr*)month=04;;
		May*)month=05;;
		Jun*)month=06;;
		Jul*)month=07;;
		Aug*)month=08;;
		Sep*)month=09;;
		Oct*)month=10;;
		Nov*)month=11;;
		Dec*)month=12;;	
		esac

#THE DATE IS NOW PUT BACK TOGETHER TO BE COMPARED TO THE #BENCHMARK
	testdate=$year$month$day  
	branchdate="20070814"


# IF THE DATE WE ARE TESTING IS OLDER THAN THE BENCHMARK, CREATE A PARTICULAR CONFIG_SPEC. OTHERWISE, PRINT THE OTHER TYPE OF CONFIG_SPEC
	
	if [[ $testdate -lt $branchdate ]]
	then
	
echo 'Generating config spec files........'

more week_ending_dates.txt | grep Jan | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}'  
	more week_ending_dates.txt | grep Feb | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}' 
	more week_ending_dates.txt | grep Mar | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}' 
	more week_ending_dates.txt | grep Apr | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}' 
	more week_ending_dates.txt | grep May | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}' 
	more week_ending_dates.txt | grep Jun | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}'
	more week_ending_dates.txt | grep Jul | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}'
	more week_ending_dates.txt | grep Aug | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}'
	more week_ending_dates.txt | grep Sep | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}'
	more week_ending_dates.txt | grep Oct | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}'
	more week_ending_dates.txt | grep Nov | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}'
	more week_ending_dates.txt | grep Dec | awk '{ print "time "$1 " \n element * .../wint_sp75_dev/LATEST \n element * .../main/LATEST " > "config_"$1}'	
		
else 
	
echo 'Generating config spec files........'	
more week_ending_dates.txt | grep Jan | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}' 

more week_ending_dates.txt | grep Feb | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}'
 
more week_ending_dates.txt | grep Mar | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}' 

more week_ending_dates.txt | grep Apr | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}'
 
more week_ending_dates.txt | grep May | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}' 


more week_ending_dates.txt | grep Jun | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}'

more week_ending_dates.txt | grep Jul | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}'

more week_ending_dates.txt | grep Aug | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}'

more week_ending_dates.txt | grep Sep | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}'

more week_ending_dates.txt | grep Oct | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}'

more week_ending_dates.txt | grep Nov | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}'

more week_ending_dates.txt | grep Dec | awk '{ print "time "$1 " \n element * .../wint_main/LATEST \n element * .../main/LATEST " > "config_"$1}'	
fi

done	
exec 3<&- 

Here are my issues and questions:

a) instead of finding the month, the script goes through all the lines of code (if Jan was read in, it will go through the rest before exiting. how do i break when the month is found/

b) when i read in dates, it seems that one particular config-spec is assigned to all dates (this includes dates that should be a different config-spec). how do i ensure that the config-spec changes accordingly.

c) is there an effecient way to accomplish my task.

Thanks for your help.

Last edited by mastachef; 10-30-2007 at 02:17 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk not clear

can anyone tell me the working of this logic. here "last" is a variable or it has it own meaning . getting confused. awk '{if (last && $2 != last) {print last, sum; sum=0} sum=sum+ $3; last = $2} END {print last, sum}' (4 Replies)
Discussion started by: scriptor
4 Replies

2. HP-UX

Script to clear filesystem

Hi, I have created a script to clear up the /var filesystem once it reaches > 90%. This is part of the script : #!/bin/bash DIR = ./adm DIR2=./adm/sw DIR3 = ./spool/mqueue DIR4 = ./adm/syslog DIR5 = ./adm/sulog DIR6 = ./tmp F1 = ./tmp/dead.letter F2 = ./adm/wtmps file1 =... (5 Replies)
Discussion started by: anaigini45
5 Replies

3. Shell Programming and Scripting

awk script to parse case with information in two fields of file

The below awk parser works for most data inputs, but I am having trouble with the last one. The problem is in the below rules steps 1 and 2 come from $2 (NC_000013.10:g.20763686_20763687delinsA) and steps 3 and 4 come from $1 (NM_004004.5:c.34_35delGGinsT). Parse Rules: The header is... (0 Replies)
Discussion started by: cmccabe
0 Replies

4. Shell Programming and Scripting

Tcl and clear case to obtain a file name as variable

proc get_view_rel_str { } { set cc_view :] end]] puts $cc_view set a puts $a set a end]] puts $a set a puts $a set a puts $a set a puts $a } get_view_rel_str this is a script in tcl with clearcase view (1 Reply)
Discussion started by: Syed Imran
1 Replies

5. Shell Programming and Scripting

awk script need to act on same file on matced case

Hello, I have a log file , i want to delete the lines of the log file which is match with 1st and 5th field with different patterns. Once it will meet with that condition it will delete that line from the log . I dont want to create any temp file over there. Successfully able to retrieve the... (1 Reply)
Discussion started by: posix
1 Replies

6. Shell Programming and Scripting

Script to Convert Upper case to Lower case

Hi All I have a script which extracts values from a Database (A persons name) and puts it into a variable in my script IE: $NAME However the Value in the DB is all in uppercase and contains the users first name and last name EG: > echo $NAME GRAHAM BOYLE > What I need is only the... (7 Replies)
Discussion started by: grahambo2005
7 Replies

7. Shell Programming and Scripting

Script needed to select and delete lower case and mixed case records

HELLO ALL, URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE. FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY and the CITY column records will be: Newyork washington ... (1 Reply)
Discussion started by: abhilash mn
1 Replies

8. Linux

SED/AWK Script to clear log file using timestamp?

I have a log file on our system which fills up with lines that have been timestamped, as follows.... 03/03/2008 10:56:06:815] (ERROR) balance: continuing session to genapp02 : 18500 03/03/2008 10:56:06:820] (ERROR) balance: continuing session to genapp02 : 18500 03/03/2008 10:56:07:003]... (2 Replies)
Discussion started by: davesimm
2 Replies

9. UNIX for Dummies Questions & Answers

Clear Case views on UNIX

Friends, I was asked to work on Clear Case after setting up. For this created a dynamic view by using the command, 'cleartool mkview -tag <view name> -stgloc viewstg'. Now I am not sure how to proceed further :-( May I request you to help me out in continuing further. I have a deadline in... (1 Reply)
Discussion started by: mmohan
1 Replies

10. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies
Login or Register to Ask a Question