![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Directory sizes loop optimization | la_womn | Shell Programming and Scripting | 6 | 05-16-2008 08:05 PM |
| loop through the directory for files and sort by date and process the first file | dsdev_123 | AIX | 1 | 01-30-2008 02:31 PM |
| changing filenames in a directory to a number within a loop | visitorQ | Shell Programming and Scripting | 30 | 12-13-2007 10:43 PM |
| copy files from one directory to another directory | zip_zip | UNIX for Dummies Questions & Answers | 5 | 09-14-2003 03:16 PM |
| moving files from a unix directory to a windows directory | gleads | UNIX for Dummies Questions & Answers | 2 | 08-29-2002 05:42 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Loop through files in a directory
Hi,
I want to write bash script that will keep on looking for files in a directory and if any file exists, it processes them. I want it to be a background process, which keeps looking for files in a directory. Is there any way to do that in bash script? I can loop through all the files like this: for i in `ls -1 \dirname\*` do .... done I can make it an endless loop llike this while [ true ] do done Thanks for all you help. R |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Why not run the process in the background ?
rladda.sh Code:
#! /bin/sh while true do for file in `ls /path/to/dir` do [[ -f $file ]] && echo "$file exists" done sleep 60 done Run the script as /path/to/rladda.sh & Vino |
|
#3
|
|||
|
|||
|
You can run the script in cron also to check for the file and process the same if it exists. Just a suggestion.
|
|
#4
|
||||
|
||||
|
Quote:
The & makes the script remain alive throughout. If done as a cron job, then once the job is done, the script exits until it is called again. My 2 cents, Vino |
|
#5
|
|||
|
|||
|
works well. thank you
Alice |
|||
| Google The UNIX and Linux Forums |