Sponsored Content
Top Forums Shell Programming and Scripting Reset while loop to loop same file multiple times Post 302861633 by tmalik79 on Wednesday 9th of October 2013 09:48:12 AM
Old 10-09-2013
Reset while loop to loop same file multiple times

Hi,
I want to read file multiple times. Right now i am using while loop but that is not working.

ex.
Code:
While read line
do
    while read line2
      do
           echo stmt1
            #processing some data based on data.,
     done < file2.txt
done < file1.txt  # This will have 10 records,

First while loop running 10 times but inter while loop is only executed 1 time , 2nd time it is not reading same file. I assume that is because same file already looped. want to overcome this issue.

Please suggest some solution.

Thanks,
Mallik.

Last edited by Franklin52; 10-09-2013 at 11:04 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop to check for file up to 3 times

Please forgive this I think rather basic question. I have been away from UNIX for a very long time and am in need of some help. I need to be able to check for the existance of a specific file name say 'file.dat' in a particular location If the file exists then run a second process (at... (2 Replies)
Discussion started by: JohnCrump
2 Replies

2. Shell Programming and Scripting

The loop was executed $count times

#!/bin/sh count=0 for i in 2 4 6 do echo "i is $i" count='expr $count + 1' done echo "The loop was executed $count times" with these scripts my output is : i is 2 i is 4 i is 6 The loop was executed expr $count + 1 times What should I do to get the value instead of 'expr... (17 Replies)
Discussion started by: ymwong
17 Replies

3. UNIX for Advanced & Expert Users

System call failed with 127 .. after 500 times when called in loop

Hi Experts, I have a code like this. ===== #include.... int main() { int count = 0; while(1){ printf("\n Interation number is: %d \n ",count); rv = system(" test.sh > log.txt " ); if (-1 == rv) { printf("Could not generate static log: error... (12 Replies)
Discussion started by: binnyjeshan
12 Replies

4. Shell Programming and Scripting

FASTEST way to loop a script 10k times

Is there any FASTEST way to loop a script 10k times my script works likes this c-randomnumbers-script -i input1.bed -g g19 -e DB >> output1 I need to run this 10k times by using consecutive outputs to get my final output i.e, output10000 c-random-script -i input1.bed -g g19 -e DB >>... (5 Replies)
Discussion started by: quincyjones
5 Replies

5. Shell Programming and Scripting

While loop reading file with multiple conditions

Hi Am trying to print the PIDs of process in a file and trying to grep any PID from that file I set the if condition as $value != "PID" and $value != "-" Assign that number to a variable Am confused since am using while loop to read the line from file and again if condition to check those... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

6. UNIX for Dummies Questions & Answers

How to remove first few characters from multiple file names without do loop?

Hi Fellows, I was wondering how I can remove first few characters from multiple file names without do loop in unix? e.g. water123.xyz water456.xyz to 123.xyz 456.xyz Thanks Paul Thanks. (3 Replies)
Discussion started by: Paul Moghadam
3 Replies

7. Shell Programming and Scripting

How to loop script for multiple file?

hi, i am running a java script on few thousand files (e1.rnk....en.rnk) but manually,. is there any way to run it automatically by changing the output directory (-out) ? thanx in advance ex: java -jar commands -res /path/e1.rnk -out /path/e1 -gui false java -jar commands -res /path/e2.rnk... (1 Reply)
Discussion started by: quincyjones
1 Replies

8. Shell Programming and Scripting

Execution of loop :Splitting a single file into multiple .dat file

hdr=$(cut -c1 $path$file|head -1)#extract header”H” trl=$(cut -c|path$file|tail -1)#extract trailer “T” SplitFile=$(cut -c 50-250 $path 1$newfile |sed'$/ *$//' head -1')# to trim white space and extract table name If; then # start loop if it is a header While read I #read file Do... (4 Replies)
Discussion started by: SwagatikaP1
4 Replies

9. Shell Programming and Scripting

Loop to execute 2 times and send an email alert

After the successful start of server, it should check the status again, if it is not running ,it should go through the loop for 2 times. Even after two times of execution if still the server is not running it should send an alert email. Please help (1 Reply)
Discussion started by: thomas9192
1 Replies

10. UNIX for Beginners Questions & Answers

Variable inside while loop got reset

hi, I am using hp unix server and not getting variable output present inside the while loop. I have tried changing the code and need to verify whether it is proper practice of code. I am expecting the output of varible RUN_FILE 3 to TRUE which i get inside the while loop. RUN_FILE 1=TRUE... (8 Replies)
Discussion started by: gowthamsoft
8 Replies
IO::Async::Timer::Periodic(3pm) 			User Contributed Perl Documentation			   IO::Async::Timer::Periodic(3pm)

NAME
"IO::Async::Timer::Periodic" - event callback at regular intervals SYNOPSIS
use IO::Async::Timer::Periodic; use IO::Async::Loop; my $loop = IO::Async::Loop->new; my $timer = IO::Async::Timer::Periodic->new( interval => 60, on_tick => sub { print "You've had a minute "; }, ); $timer->start; $loop->add( $timer ); $loop->run; DESCRIPTION
This subclass of IO::Async::Timer implements repeating events at regular clock intervals. The timing may or may not be subject to how long it takes the callback to execute. Iterations may be rescheduled runs at fixed regular intervals beginning at the time the timer was started, or by a fixed delay after the previous code has finished executing. For a "Timer" object that only runs a callback once, after a given delay, see instead IO::Async::Timer::Countdown. A Countdown timer can also be used to create repeating events that fire at a fixed delay after the previous event has finished processing. See als the examples in "IO::Async::Timer::Countdown". EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters: on_tick Invoked on each interval of the timer. PARAMETERS
The following named parameters may be passed to "new" or "configure": on_tick => CODE CODE reference for the "on_tick" event. interval => NUM The interval in seconds between invocations of the callback or method. Cannot be changed if the timer is running. first_interval => NUM Optional. If defined, the interval in seconds after calling the "start" method before the first invocation of the callback or method. Thereafter, the regular "interval" will be used. If not supplied, the first interval will be the same as the others. Even if this value is zero, the first invocation will be made asynchronously, by the containing "Loop" object, and not synchronously by the "start" method itself. reschedule => STRING Optional. Must be one of "hard", "skip" or "drift". Defines the algorithm used to reschedule the next invocation. "hard" schedules each iteration at the fixed interval from the previous iteration's schedule time, ensuring a regular repeating event. "skip" schedules similarly to "hard", but skips over times that have already passed. This matters if the duration is particularly short and there's a possibility that times may be missed, or if the entire process is stopped and resumed by "SIGSTOP" or similar. "drift" schedules each iteration at the fixed interval from the time that the previous iteration's event handler returns. This allows it to slowly drift over time and become desynchronised with other events of the same interval or multiples/fractions of it. Once constructed, the timer object will need to be added to the "Loop" before it will work. It will also need to be started by the "start" method. AUTHOR
Paul Evans <leonerd@leonerd.org.uk> perl v5.14.2 2012-10-24 IO::Async::Timer::Periodic(3pm)
All times are GMT -4. The time now is 02:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy