Added newdev() which uses inotifywait to list new files in the specified path, or /dev/ if unspecified
This commit is contained in:
parent
d73734401e
commit
473e1e8f56
|
@ -0,0 +1,27 @@
|
||||||
|
newfiles() {
|
||||||
|
|
||||||
|
# Path to watch. If the first parameter isn't set, just use /dev/
|
||||||
|
local path="${1:-/dev/}"
|
||||||
|
|
||||||
|
# Seconds without new events before exiting inotifywait
|
||||||
|
local timeout=10
|
||||||
|
|
||||||
|
printf "New files in %s:\n\n" "$path"
|
||||||
|
|
||||||
|
inotifywait \
|
||||||
|
--monitor \
|
||||||
|
--event create \
|
||||||
|
--timeout $timeout \
|
||||||
|
--format '%w%f' \
|
||||||
|
--quiet \
|
||||||
|
"$path"
|
||||||
|
|
||||||
|
local return=$?
|
||||||
|
if [[ $return == 2 ]]; then
|
||||||
|
printf "\nNo new events in %s seconds. Exiting.\n\n" $timeout
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
printf "\nE: inotifywait returned %s. Exiting.\n\n" $return
|
||||||
|
return $return
|
||||||
|
fi
|
||||||
|
}
|
Loading…
Reference in New Issue