Ctrl+Z and fg to append commands
Posted
by
avilella
on Super User
See other posts from Super User
or by avilella
Published on 2011-11-27T00:10:23Z
Indexed on
2011/11/27
1:53 UTC
Read the original article
Hit count: 465
I would like to know what is the behaviour of Ctrl+Z and fg in bash when wanting to append commands to be executed after a running command has finished. For example, in the sequence for commands below, I would expect the console to display "1", then "2", then "3", then "4", but I only get the last command, echo 4, after sleep 30 finishes:
avilella@magneto:~$ sleep 30 && echo 1
^Z
[1]+ Stopped sleep 30
avilella@magneto:~$ fg && sleep 5 && echo 2
sleep 30
^Z
[1]+ Stopped sleep 30
avilella@magneto:~$ fg && sleep 5 && echo 3
sleep 30
^Z
[1]+ Stopped sleep 30
avilella@magneto:~$ fg && sleep 5 && echo 4
sleep 30
4
Any ideas?
© Super User or respective owner