I think generate temp file may slower and if user press ctrl+c the temp file will become garbage.
Here is my original code
for f in bin/* ; do
ldd $f 2>/dev/null | awk '{print $1}'
done | sort -u | grep -v -e '^not$' -e 'ld-linux' > list.1
while read soname ; do
process_so_name $soname
done < list.1
Is it possible to remove the temp file list.1?
Just do it without a temp file. Pipe the result of the last grep into the while.
You can hook into SIGINT to detect Ctrl+C, but why worry if you don’t need to? You still won’t be able to hook into SIGKILL.
You can make this look more recognizable by placing the loops in functions (you can do this in a script file or right in the shell):
To hook into SIGINT, do something like this:
To hook into SIGTERM (see comments underneath), do this: