Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening multiple file descriptors

Status
Not open for further replies.

AD666

MIS
Jun 18, 2003
1
AU
I need to write a more efficient way for the code below :

Just a simplified example:
cnt=50000
while [ cnt -ne 0 ]
do
echo "aaaa" >> file1
echo "bbbb" >> file2
((cnt=cnt-1))
done

The problem I have is that the files im creating are getting bigger and bigger and the time it takes to open them is obviously getting longer. The time it takes to complete this script is far too long. I need a better way to write to multiple files within a while loop.
Thanks in advance.
Alex
 
Try this:
Code:
exec 3>file1 4>file2
cnt=50000
while [ cnt -ne 0 ]
do
   echo "aaaa" >&3
   echo "bbbb" >&4
   ((cnt=cnt-1))
done


Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top