Computing.Net > Forums > Unix > For Loop Iteration

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

For Loop Iteration

Reply to Message Icon

Name: munish
Date: January 10, 2006 at 20:24:49 Pacific
OS: Unix
CPU/Ram: na
Comment:

I am creating a script in which I have to
note down the size of the files which are in
different directory.
Suppose:-
In log dir :
A1.txt
A2.txt
A3.txt
A4.txt

and in dat directory"
A4.txt
A5.txt
A6.txt
A2.txt
A1.txt
A3.txt

I want to create a script which can give me
the file size of those files which have the
same name in both the folders.

For this I have create a for loop.

First for loop do the ls and then
there is a second internal for loop which
runs under the first for loop which checks
whether the file which is in the log directory exists in the dat directory,
if it matches, it stores the result in the
result.txt file having the file size of
both the files.

The problem I am having with for loop is
its skipping some files while iterating
through the list of the files.

Please post an example so that I have
some idea what I am missing.

Thanks.



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: For Loop Iteration

problem with grep in a for loop www.computing.net/answers/unix/problem-with-grep-in-a-for-loop/3967.html

Unix for loop www.computing.net/answers/unix/unix-for-loop/3717.html

why isn't this for loop working?? www.computing.net/answers/unix/why-isnt-this-for-loop-working/6915.html