Process some Folders and format the output
1
vote
1
answer
78
views
In Linux there are some Folders.
I want to process each of this Folders with the program
myprogramm
.
I get a list with ls -1
or much better, sure only Folders with:
find . -maxdepth 1 -type d -printf '%f\n' | tr -d '.' | sed '/^[[:space:]]*$/d'
I Can pipe this to xargs.
xargs -I {} -n1 -P1 $(cat $TEMPDIR)/myprogramm -switch1 -switch2 -someoptions {}/ -o {}.info
In one line :
find . -maxdepth 1 -type d -printf '%f\n' | tr -d '.' | sed '/^[[:space:]]*$/d' | xargs -I {} -n1 -P1 $(cat $TEMPDIR/pwd)/myprogramm -switch1 -switch2 -someoptions {}/ -o {}.info
That works so far.
But i am looking for a way to bring a little bit info into it.
Everytime if myprogramm
ends, it would be nice to have an output like: Folder 1 of 22 finished
Count how many Folders exist can i do with:
find . -maxdepth 1 -type d -printf '%f\n' | tr -d '.' | sed '/^[[:space:]]*$/d' | wc -l
But how to bring this into the line they process each Folders? And how to count after every one is finished one up?
Next thing, how to bring a random sleep value after every finished myprogramm
run and count them down before to work at the next Folder?
A random sleep can do with sleep $(shuf -i 30-60 -n 1)
.
But how to bring this into, and how to show and count them down?
Asked by Banana
(189 rep)
Jul 13, 2025, 02:26 AM
Last activity: Jul 13, 2025, 04:47 PM
Last activity: Jul 13, 2025, 04:47 PM