Every now and then I have to kill a for loop that looks through hundreds of directories for something and I have yet to find a way to do it with a single command. Every time I do it just skips that directory and moves onto the next until it's gone through them all. How can I stop the entire thing with just a single command?
Example:
for index in $(ls -1 /path/to/direcorties)
do
find $index -name some_file.gz | awk -F/ '{print $2}' >> /other/path/file.txt
done
If I have to kill this all it does it skip the directory it's in and moves to the next which means I have to kill the new PID for every directory in the list until it's gone through them all.
sl
command to accept interrupts, for that question's particular command). – Jeff Schaller Apr 03 '19 at 19:12