Skip to main content
1 of 2
The Sidhekin
  • 846
  • 1
  • 6
  • 8

Job control lets you put it in the background and get it back in foreground again:

time ( set -m; sleep 10 & echo $! ; fg >/dev/null ; )

Hmm … the complete command winds up as a stopped job, though. Odd. Here's a workaround:

bash -c ' time ( set -m; sleep 10 & echo $! ; fg >/dev/null ; ) '

Of course, by then it might as well be:

bash -c ' time { set -m; sleep 10 & echo $! ; fg >/dev/null ; } '

I'd prefer avoiding that bash -c, but I'm kinda fresh out of ideas. :-\

The Sidhekin
  • 846
  • 1
  • 6
  • 8