reading file,looping and limitation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting reading file,looping and limitation
# 1  
Old 10-27-2011
reading file,looping and limitation

I have 2 functions on AIX.
Func_A () {
....
....
}
Func_B () {
....
....
}
And I have a abc.txt file (multiple lines) and I would like to read line by line and pass line by line to Func_A & Func_B.
once Func_A is done,pass same value to Func_B and in the mean time get second line from txt file and pass it to Func_A
and only 4 lines can be active any given moment.

Example
line_1 --> Func_A (done) ---> continue with Func_B (processing)
line_2 --> Func_A (done) ---> continue with Func_B (processing)
line_3 --> Func_A (done) ---> continue with Func_B (processing)
line_4 --> Func_A (done) ---> continue with Func_B (processing)

I want to wait until func_B is done for line_1 before I continue reading the line_5. Please let me know if I am not explain well?

Appreciate all the help in advance. Thanks
# 2  
Old 10-27-2011
You can start from this:
Code:
while read line
do
  Func_A $line
  Func_B $line
done <abc.txt

# 3  
Old 10-28-2011
Thanks. Reading a file is not an issue. I can't straighten up the logic, how can I read second line while first line is working on Func_B and how can I limit 4 lines?

Thanks.
# 4  
Old 10-28-2011
If you can't straighten the logic and you can't straighten the function, what are you allowed to change?
# 5  
Old 10-28-2011
What I meant was, I can't figure out how to handle read of second line while working on first line (Func_B is still processing line_1) and limit them at 4.
# 6  
Old 10-28-2011
Use a control variable:
Code:
controlVar=1
while read line
do
	if [ ${controlVar} -eq 1 ]
	then
		Func_A "${line}"
	elif [ ${controlVar} -eq 2 ]
	then
		Func_B "${line}"
	elif [ ${controlVar} -eq 3 ]
	then
		Func_C "${line}"
	elif [ ${controlVar} -eq 4 ]
	then
		Func_D "${line}"
		controlVar=1
	fi
	controlVar=`expr ${controlVar} + 1`
done <abc.txt

EDIT: Sorry, after I posted I read the topic carefully!

I could not understand what the OP wants!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

File size limitation in Linux

Hi friends, I tried to take a backup of my PC using tar command. But it ended with an error tar: /home/backup/back.tar.gz: Cannot write: No space left on device tar: Error is not recoverable: exiting now But i checked the disk space and there is enough space is available. ]# df Filesystem... (11 Replies)
Discussion started by: siva3492
11 Replies

2. HP-UX

NFS file transfer limitation

Hello friends, i hace a problem in nfs file transfer i mounted hp-unix directory into linux directory the command i used: mount <IP_Address>:/home/new /usr/new i have already done everything in linux side for exporting. then i tried to copy a file which one size is 18 gb but file... (5 Replies)
Discussion started by: siva3492
5 Replies

3. UNIX for Dummies Questions & Answers

Looping/Reading file contents not working

Hi, I am doing something basic, but I am missing something. Im trying to read the contents of a file and taking those values and connecting to a database. However, it only connect to one (or reads in) value and then exists. Here is what it looks like: listname.txt db1 db2 db3 Script:... (15 Replies)
Discussion started by: DBnixUser
15 Replies

4. Solaris

How to extend 2 GB file size limitation

Hello All, I am using a SunOS machine. My application creates output files for the downstream systems. However output files are restricted to 2GB of file size in SunOS due to which I am forced to create multiple files which is not supported by the downstream due to some limitations. Is... (5 Replies)
Discussion started by: pasupuleti81
5 Replies

5. Shell Programming and Scripting

fetchmail - log file size limitation

Hi, I am using fetchmail in my application so as to download mails to the localhost where the application is hosted from the mailserver.Fetchmail is configured as as to run as a daemon polling mails during an interval of 1sec. So my concern here is, during each 2sec it is writing two... (10 Replies)
Discussion started by: DILEEP410
10 Replies

6. UNIX for Dummies Questions & Answers

Unix -- Space problem -- File number limitation?

Dear all Recently I cant touch file in one mount point (which is not full, 78% full only), it says can't write to device, obviously it means it's full, I deleted some files and I can write some files only. I wonder is there any file number limitation in a mount point and how can I check or how... (2 Replies)
Discussion started by: shanemcmahon
2 Replies

7. Linux

File size limitation for rcp

Hi I am trying to rcp a file from Solaris box to Linux. When the file size is 2,205,255,047, the rcp fails with the message Jan 10 01:11:53 hqsas167 rsh: pam_authenticate: error Authentication failed However when I rcp a file with smaller size - 9,434,477 - the rcp completes with... (2 Replies)
Discussion started by: schoubal
2 Replies

8. Shell Programming and Scripting

File size limitation of unix sort command.

hi , iam trying to sort millions of records which is delimited and i cant able to use sort command more than 60 million..if i try to do so i got an message stating that "File size limit exceeded",Is there any file size limit for using sort command.. How can i solve this problem. thanks ... (7 Replies)
Discussion started by: cskumar
7 Replies

9. HP-UX

HP-UX 11i - File Size Limitation And Number Of Folders Limitation

Hi All, Can anyone please clarify me the following questions: 1. Is there any file size limitation in HP-UX 11i, that I can able to create upto certain size of file (say 2 GB) and not more then that???? 2. At max. how many files we can able to keep inside a folder???? 3. How many... (2 Replies)
Discussion started by: sundeep_mohanty
2 Replies

10. Solaris

unix group file limitation

Does anyone know how to get around the unix group file limitation whereby you have a limit of 1024 characters when adding users to a unix group? (3 Replies)
Discussion started by: asmillie
3 Replies
Login or Register to Ask a Question