For loop to read folder which are not under processing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting For loop to read folder which are not under processing
# 1  
Old 06-10-2012
For loop to read folder which are not under processing

Hi,

I want to read folders which do not have a file "processing" in a for loop ordered by timestamp.
Currently im doing like this.

Like
Code:
cd /home/working
for i in `ls -c1`
do
some command...
done

I want to exclude folders which have that "processing" file.
The directory contains only directories.

Thanks,
Chetan.C

Last edited by chetan.c; 06-10-2012 at 11:15 AM.. Reason: Added more info
# 2  
Old 06-10-2012
Quote:
Originally Posted by chetan.c
Code:
for i in `ls -c1`


Command substitution is almost always the wong way to get a list of files. Instead, feed the output of ls to a loop:
Code:
ls -c |
 while IFS= read -r dir
 do
   [ -e "$dir/processing" ] && continue ## do nothing if processing file exists
   : do whatever with directories containing "processing"
 done

This User Gave Thanks to cfajohnson For This Post:
# 3  
Old 06-11-2012
Thanks johnson!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Processing too slow with loop

I have 2 files file 1 : contains ALINE ALINE BANG B ON A B.B.V.A. BANG AMER CORG BANG ON MORENA BANG ON MORENAIC BANG ON MORENAICA BANG ON MORENAICA CORP BANG ON MORENAICA N.A file 2 contains and is seprated by ^ delimiter : NATIO MARKET^345432534 (10 Replies)
Discussion started by: nikhil jain
10 Replies

2. Shell Programming and Scripting

I want to read the content of a specific folder

Why does not work a cd in a shell schript file. How do you get to run it? I use these code: #!/bin/sh cd workspace array=($(ls -d */)) echo ${array} But it doesn't change to workspace editby bakunin: please user CODE-tags as required by the rules. Thank you. (12 Replies)
Discussion started by: Linuxmann
12 Replies

3. UNIX for Dummies Questions & Answers

Loop for file merging in a folder

Dear all, I have a few files in a folder (lets say 5) and each have a few lines in them. I want to create merges of each of them with the other ones e.g. I need the following merges I tried to write a loop and started with combinations of 2, I get the write file names but for each... (17 Replies)
Discussion started by: A-V
17 Replies

4. HP-UX

Lost Read permission on my folder

Hi I am a normal user on a HP-UX system which is meant for a large group. There are few directories which I think i am owner of. (Name of these directories is same as my username, and I usually have all the permissions in these directories). I was trying to give read and execute... (2 Replies)
Discussion started by: grvs
2 Replies

5. UNIX for Dummies Questions & Answers

Read statement within while read loop

hi, this is my script #!/bin/ksh cat temp_file.dat | while read line do read test if ]; then break else echo "ERROR" fi done when i execute this code , the script does wait for the user input . it directly prints "ERROR" and terminates after the no. of times as there... (3 Replies)
Discussion started by: siva1612
3 Replies

6. Shell Programming and Scripting

How read the name of present folder into a variable???

Dear all, Now I have a bunch of files need to be renamed. For instance, I have ten files in a folder with a name 'olefin', and I would like to change all the ten files name into 'olefin01,olefin02,...,olefin10'. I suppose it can be done with the command 'pwd'. However, the command 'pwd' will... (7 Replies)
Discussion started by: liuzhencc
7 Replies

7. Shell Programming and Scripting

bash - batch processing folder of files by name

Hello Everyone!!! I need some help with a shellscript to batch process a folder of files with the imagemagick convert -append/+append command. The folder contains some hundred or thousand of small images in .png format which I would like to join together in order of their filenames. The... (3 Replies)
Discussion started by: imtombi
3 Replies

8. Shell Programming and Scripting

How to read a subfolder one by one in parent folder?

Hi friends, I am getting some trubles in folder reading. I am having 10 subfolders inside server7 folder. i wanna to read a subfolder name first and check if the foldername gets started with "http". if so , i need to read a file inside that folder. This willl continue for... (1 Reply)
Discussion started by: kamatchirajan
1 Replies

9. Shell Programming and Scripting

Why does this only read the one folder?

for j in folder1 folder2 folder3 folder4 folder5 do find /tmp/$j -type f -newer /tmp2/newer.txt -exec cp {} /thisfolder1/ \; done. this only reads from folder1 and not the other folders. What's the problem here? (3 Replies)
Discussion started by: bbbngowc
3 Replies

10. Shell Programming and Scripting

read from folder

Collegues I have a number of files in a folder. Each file I would like to exicute one shell script . How to do it in shell With tanks and regards Jaganadh.G (2 Replies)
Discussion started by: jaganadh
2 Replies
Login or Register to Ask a Question