Sponsored Content
Top Forums Shell Programming and Scripting problem in while loop in a script Post 302247648 by ali560045 on Thursday 16th of October 2008 06:23:39 AM
Old 10-16-2008
problem in while loop in a script

i have a script that will read each line and then grep a particular pattern and do some_stuff. Below the script

while read j
do
q1=0
q1=`$j | grep 'INFO - LPBatch:' | wc -l`
if [ $q1 -eq 1 ]
then
$j | tr -s " " | cut -d " " -f8,42,43 >> nav1.txt
fi

q2=0
q2=`$j | grep 'INFO - Number of Intervals Not Inserted:' | wc -l`
if [ $q2 -eq 1 ]
then
$j | tr -s " " | cut -d " " -f6-13 >> nav1.txt
fi
done < nav11.txt
-----------------------------------------------------------------------

below some of the lines of the file nav11.txt


2008-10-14 05:47:05,551 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 1

2008-10-14 05:47:05,551 [Thread-6] INFO - LPBatch: [null, 1-GH32X, null, DC:Tue Oct 14 10:12:37 UTC 2008, null, null, Mon Oct 13 05:00:00 CDT 2008, Mon Oct 13 10:00:00 UTC 2008, Tue Oct 14 04:45:00 CDT 2008, Tue Oct 14 09:45:00 UTC 2008, CC, AMR, 94]

2008-10-14 05:47:05,575 [Thread-6] INFO - Number of Intervals Not Inserted: 1 / 95

2008-10-14 05:02:56,762 [Thread-6] ERROR - CleanLPDataMessage: Missing Intervals: 3

2008-10-14 05:02:56,763 [Thread-6] INFO - LPBatch: [null, 1-VIN74, null, DC:Tue Oct 14 09:29:49 UTC 2008, null, null, Mon Oct 13 04:00:00 CDT 2008, Mon Oct 13 09:00:00 UTC 2008, Tue Oct 14 04:00:00 CDT 2008, Tue Oct 14 09:00:00 UTC 2008, CC, AMR, 97]

2008-10-14 05:02:56,763 [Thread-7] INFO - Register Read: [1-X22K8, 0.0, Tue
------------------------------------------------------------------------

the while part is having some problem.can anyone help me in this?

Last edited by ali560045; 10-16-2008 at 08:05 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script loop problem

I am writing a shell script that simulates the `wc -w` command without actually using wc itself. My problem is that the script will only read the first line of the file and just keep looping through it. I have tried both while and for loops and got the same result. Can anyone help? ... (1 Reply)
Discussion started by: MaxMouse
1 Replies

2. UNIX for Dummies Questions & Answers

have a problem with if elif loop .. plz help me with the script

count2=0 var2=NOT if then echo"Loop1" command="egrep ',$var1," if then echo "the command is OR" command=$command"|,$var3," echo "$command" elif then command=$command"| egrep ',$var3," else ... (4 Replies)
Discussion started by: Syms
4 Replies

3. Shell Programming and Scripting

Problem with while loop in shell script

Hi All, How to read a file upto last line(End Of Line) I wrote below program: cat R2_20060719.610.txt | while read LINE do echo "$LINE" done above code reading all lines from a file and skipping last line...... is there anything wrong in my code. Please help me out from this... (20 Replies)
Discussion started by: rkrgarlapati
20 Replies

4. Shell Programming and Scripting

while loop problem in c shell script

Hi all, i write a script c shell set i = 1 while ( $i <= $#array ) echo "$array" @ i++ end i want to set it to i = i +2 in that statement . Can anybody help me? ---------- Post updated at 02:46 PM ---------- Previous update was at 02:35 PM ---------- anybody not how to solve it??? (2 Replies)
Discussion started by: proghack
2 Replies

5. Shell Programming and Scripting

How to loop use while loop in csh script?

Hi all, i got 2 text file. file.txt value.txt i want use C shell script to write out while both of the file got different limit....how i going to write it in 1 while loop? (4 Replies)
Discussion started by: proghack
4 Replies

6. UNIX for Dummies Questions & Answers

simple script with while loop getting problem

Hello forum memebers. can you correct the simple while program. #! /bin/ksh count=10 while do echo $count count='expr$count-1' done I think it will print 10 to 1 numbers but it running for indefinite times. (2 Replies)
Discussion started by: rajkumar_g
2 Replies

7. Shell Programming and Scripting

Problem passing a search pattern to AWK inside a script loop

Learning, stumbling! My progress in shell scripting is slow. Now I have this doubt: I have the following file (users.txt): AU0909,on AU0309,off AU0209,on AU0109,off And this file (userson.txt) AU0909 AU0209 AU0109 AU0309 I just want to set those users on userson.txt to "off" in... (14 Replies)
Discussion started by: quinestor
14 Replies

8. Linux

Problem with my loop and awk script

Sorry if this is a super simple issue, but am extremely new to this and am trying to teach myself as I go along. But can someone please help me out? I have a data file similar to this for many samples, for all chromosomes Sample Chr bp p roh Sample1 1 49598178 0 1... (14 Replies)
Discussion started by: vuvuzelo
14 Replies

9. Shell Programming and Scripting

Problem with loop within loop

Hi, I work on Ab-initio ETL tool which is based on Unix. I made a small script which has two loop's one with in another. All the functionality is working for the first line of outer loop but when it comes to other lines of outer loop it is throwing error as command not found. Below is the... (4 Replies)
Discussion started by: Ravindra Swan
4 Replies

10. Shell Programming and Scripting

PERL script loop problem

I have written the below PERL script to reprocess messages from a failure queue. It basically browses all the messages in the failure queue to individual files in a directory and then scans those files to determine the originating queue. The script will then move each message in turn from the... (0 Replies)
Discussion started by: chris01010
0 Replies
SHCOMP(1)						       Korn shell utilities							 SHCOMP(1)

NAME
shcomp - compile a shell script SYNOPSIS
shcomp [ options ] [infile [outfile]] DESCRIPTION
Unless -D is specified, shcomp takes a shell script, infile, and creates a binary format file, outfile, that ksh can read and execute with the same effect as the original script. Since aliases are processed as the script is read, alias definitions whose value requires variable expansion will not work correctly. If -D is specified, all double quoted strings that are preceded by $ are output. These are the messages that need to be translated to locale specific versions for internationalization. If outfile is omitted, then the results will be written to standard output. If infile is also omitted, the shell script will be read from standard input. OPTIONS
[D dictionary] Generate a list of strings that need to be placed in a message catalog for internationalization. [n noexec] Displays warn- ing messages for obsolete or non-conforming constructs. [v verbose] Displays input from infile onto standard error as it reads it. EXIT STATUS
0 Successful completion. >0 An error occurred. SEE ALSO
ksh(1) IMPLEMENTATION
version shcomp (AT&T Research) 2003-03-02 author David Korn <dgk@research.att.com> copyright Copyright (c) 1982-2010 AT&T Intellectual Property license http://www.opensource.org/licenses/cpl1.0.txt 2003-03-02 SHCOMP(1)
All times are GMT -4. The time now is 05:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy