HackerTrans
TopNewTrendsCommentsPastAskShowJobs

i15e

22 karmajoined 7 वर्ष पहले

comments

i15e
·17 घंटे पहले·discuss
I'm not seeing any ? marks in my code. Are you referring to the instances of $'\t'? In bash (and other shells, including recent versions of the POSIX sh specification) $'...' is treated like a C-style string complete with backslash escape sequences, so $'\t' is a way to have a tab character as a part of a command argument.
i15e
·19 घंटे पहले·discuss
A variant:

  docker image ls -a | stdbuf -oL sed -r 's/\s{2,}/\t/g' | { head -n1; tail -n+2 | sort -hrk5 -t$'\t'; } | column -ts$'\t'
I used docker since that's what I have installed and I assume the output is equivalent.

sort's -t is set to tab for field separation.

stdbuf sets sed's output to only buffer a line at a time and flush, so the head in the {...} command group doesn't completely consume stdin's contents before it's passed to tail.

The column command recreates the space-aligned table based on tab-delimited input.
i15e
·7 माह पहले·discuss
You can use Ctrl+z to suspend the foreground process, bg to resume it in the background, and then wait to wait for it to complete. By default wait will wait for all jobs to finish and then return a success exit code, however if you give it a specific job ID it will instead return the exit code of the waited-on process:

    $ (sleep 10; false)
    ^Z
    [1]+  Stopped                 ( sleep 10; false )
    $ wait %% && echo ok || echo nok
    [1]+  Exit 1                  ( sleep 10; false )
    nok