Einstein47
Programmer
I have a question about CTRL-C.
When I run the following script from the command-line it will show me the daily log, and then when I hit Ctrl-C it pauses then restarts the tail on the daily log (this is because each day has a new daily log, and I just need to hit Ctrl-C and the current day's log is tailed).
However, when I put that exact code in a script file, it doesn't work. CTRL-C causes the script to end. Is there a way to trap the CTRL-C just durring the tail -f part but then re-enable the default behavior after the echo statement?
Einstein47
“Evil abounds when good men do nothing.“ - Nelson R.
[[]Starbase47.com]
When I run the following script from the command-line it will show me the daily log, and then when I hit Ctrl-C it pauses then restarts the tail on the daily log (this is because each day has a new daily log, and I just need to hit Ctrl-C and the current day's log is tailed).
Code:
while [ 1 -eq 1 ]; do
clear
tail -f daily.log
echo "Hit CTRL-C Again to quit"
sleep 5
done
However, when I put that exact code in a script file, it doesn't work. CTRL-C causes the script to end. Is there a way to trap the CTRL-C just durring the tail -f part but then re-enable the default behavior after the echo statement?
Einstein47
“Evil abounds when good men do nothing.“ - Nelson R.
[[]Starbase47.com]