1

I would like to create a script that get's all the folders names in another folder. And execute a script for the names of these folder for lets say every 30 seconds.

So for example we have a folder named "Test" in the root

Under this folder there are 3 other folders named: "One", "Two", "Three"

So like this:

/ ├── Test │ ├── One │ ├── Two │ ├── Three

And now i want that all the folders in the folder Test automatically run in a script lets say for example i want to echo the folder names every 30 seconds.

So every 30 seconds on my screen i see:

One Two Three

Because currently all the folders are "One", "Two" and "Three".

But when i add another folder, lets say "Four". That my script automatically echo's this folder too. So i will get this every 30 seconds.

One Two Three Four

Could anybody tell me how i can get this done in a bash script?

1 Answers1

2

You can use watch command for this:

watch -n 30 "ls -1 /Test"

Watch executes a command every -n seconds and displays the result of latest run on screen.

Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115