Write a linux bash script that enables user to create his resume make sure that the assigned value doesn't change.
#!/bin/sh
trap trapInt INT
trapInt(){
echo 'Paused. Enter q to quit, something else to resume.'
read reply
[ "$reply" = "q" ] && exit
}
i=$$
while :; do
sleep 1
echo $$,$i
i=$((i+1))
done
The main block of the script is just a infinite loop, composed
of a 1 second sleep, an echo of the PID of the shell
($$
) and an incrementing number ($i
).
Upon receiving the INT signal, the running command is
interrupted and the function trapInt
is executed.
$ ./v.sh
11136,11136
11136,11137
11136,11138
^CPaused. Enter q to quit, something else to resume.
<-- typed <Enter>
11136,11139
11136,11140
11136,11141
^CPaused. Enter q to quit, something else to resume.
q <-- typed <q><Enter>
$
Get Answers For Free
Most questions answered within 1 hours.