How to disable a group of commands in Bash

I fiddled with the Linux team "timeout" command: it just stops the long command after the given seconds. But I would like to disable not only the team, but also the team of teams. I can group a command in two ways () and {;}, but none of the following works:

timeout 1 { sleep 2; echo something; }
timeout 1 ( sleep 2; echo something )

How can I do this with a grouping?

+4
source share
2 answers

timeoutIt is not a shell utility and does not perform shell-style processing. He must be given one command to execute. However, this command can have any number of arguments. Fortunately, one of the commands you can give is bash:

timeout 1 bash -c '{ sleep 2; echo something; }'

, :

timeout 1 bash -c 'sleep 2; echo something'

bash - , timeout. -c sleep 2; echo something .

+7
timeout 1 sh -c "sleep 2; echo something"
+3

All Articles