how to check folder if it has files in it using Bash Shell script
Good day gurus!
Say, there is a folder. Its empty. When every I drag a new file and put into it it echo out "there is file in there" and keep monitoring the folder. How can I do it? Before dragging file into the folder it should appear [admin@linux shell]$ folder is being monitor.... when I drag a file into the folder it say [admin@linux shell]$ There is file in folder..... If no action to be taken, after 300 seconds, it appears like [admin@linux shell]$ There is file in folder..... There is file in folder..... And it keeps going on. Its kinda monitoring and warning people Please advise... Thanks in advance |
you can use the below script, I am using it for /tmp you can give any directory (absoulte path) here
Code:
fname=/tmp |
Here's an idea. Needs folder name passing to the script. Should have error trap for folder not existing, including when script called without being passed the folder name.
Code:
#!/bin/bash |
The linux facility for watching for changes is "inotify", and there's a package inotify-tools to use it from the shell. "inotifywait" in that package does everything you want.
|
thanks for your help. I appreciate it
|
Quote:
|
However, I come up with this solution:
Quote:
Anyway, thanks for you helps guys!!! |
Nice work - you got a working solution. If you are happy with that, you can mark this [SOLVED] using "Thread Tools" above the first post.
P.S. - it might make for a nicer (easier to read) display output from the script, if you put a "clear" command after the "sleep" command. Cheers, Sasha |
All times are GMT -5. The time now is 07:44 PM. |