02-04-2007
The number and total size of the files is irrelevant.
All new files will not be affected by whatever happens inside the for loop.
If you want them to be affected as well you could put the for loop e.g. inside a while loop.
Suppose your for loop works on files with the extention ".txt".
while [ `ls *.txt > /dev/null 2>&1; echo $?` -eq 0 ]
do
for FILE in `ls *.txt`
do
do_whatever_needs_to_be_done
done
done
The while loop makes sure that as long as *.txt files are present in the directory the for loop will be executed over and over.
Ofcourse this process will come to an end at sometime as well, when no more *.txt are present. New *.txt files arriving shortly after are not affected either.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Excuse me for this question really for dummies!
I would like to know how sendmail works, obviously even in few words.
If it uses a mail server or relay to send mail, if there is some check that sendmail makes to the from address and so on...
Thank you very much. (3 Replies)
Discussion started by: alzep
3 Replies
2. UNIX for Dummies Questions & Answers
ls displays files in tabbed output. Say a directory contains 3 files. ls will list all 3 in one line. So, I expect ls | wc -l to give 1, but it counts the nr of files and gives 3.
Can someone explain how this works? (3 Replies)
Discussion started by: krishmaths
3 Replies
3. Shell Programming and Scripting
I am trying to get a count of each line
sub runit2 {
my ($file1a, $file2a) = @_;
my $file1_vala = $file1a->get;
my $file2_vala = $file2a->get;
open (FILE1a, "$file1_vala") or die;
open (FILE2a, "$file2_vala") or die;
chomp(my @strings = <FILE2a>);
while (1) {
foreach $pattern... (4 Replies)
Discussion started by: popeye
4 Replies
4. Programming
pls explain me how this works....
DECODE (SUBSTR (field, 1, 1),'''', '''''' || field || '''','''' || field || '''')
here field is a column in an oracle table.... (7 Replies)
Discussion started by: vijay_0209
7 Replies
5. Solaris
HI,
Just another dummies questions:
How i can determine what number of inode to use when creating filesystem?
Thanks (4 Replies)
Discussion started by: lamoul
4 Replies
6. UNIX for Dummies Questions & Answers
When I try to execute script, I get message:
>aa.pl
zsh: command not found: aa.pl
but
>./aa.pl
works OK.
What to change in environment to force the former way to work?
Thank you,
Alex Z (4 Replies)
Discussion started by: zzol
4 Replies
7. UNIX for Advanced & Expert Users
I have a program............
#include<stdio.h>
#include<unistd.h>
main()
{
if(fork == 0)
{
printf("Hi every body:p!!!!!!!!!!");
}
}
This program works with out any error. here fork is not a system call. It just act as a variable.But how it works without declaring it? What data type it... (19 Replies)
Discussion started by: carolsanjeevi
19 Replies
8. Shell Programming and Scripting
I found this command, sed -e 's/<*>//g', will return the content of a line with pattern something like this, <tag1>content</tag1>..
How does this works?
What does sed -e 's/<*>//g' actually do?
What if I wanted to get content of a line with pattern something like this, content?
thanks.. (5 Replies)
Discussion started by: 14th
5 Replies
9. Shell Programming and Scripting
Here's my code:
awk -F '' 'NR==FNR {
if (/time/ && $5>10)
A=$2" "$3":"$4":"($5-01)
else if (/time/ && $5<01)
A=$2" "$3":"$4-01":"(59-$5)
else if (/time/ && $5<=10)
A=$2" "$3":"$4":0"($5-01)
else if (/close/) {
B=0
n1=n2;
... (2 Replies)
Discussion started by: klane
2 Replies
10. UNIX for Beginners Questions & Answers
Hi there, this may be a beginner's error, but I've been unable to find a solution on my own and by googling, and now I am really stuck on it.
I am simply trying to move directories called for example CAT_Run01.ica to a directory with the corresponding number, Run01, in the same directory.
For... (2 Replies)
Discussion started by: andrevol
2 Replies