News for hackers. Stuff that matters.

i15e

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.
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.

Re:Ask HN: Extendable" Shell Commands? on Thursday December 11, 2025 @06:10PM (#46238645)
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
Re:WinDirStat – Windows Directory Statistics on Thursday May 23, 2024 @09:58AM (#40454817)
You could install the Google Drive client and then run WinDirStat against the virtual drive letter that it creates:

https://support.google.com/drive/answer/10838124

Re:What We're Working on in Firefox on Wednesday May 22, 2024 @10:23AM (#40441395)
In Firefox you can go to about:profiles to easily open new windows using other profiles. I bookmark that page with a keyword for quick access. (Also see about:about for a list of other handy 'about' pages)

A more classic-style profile switcher is available via the '-P' (or '-ProfileManager') command-line switch. If FF is in your $PATH you can run:

  firefox -P
The '-P' switch can also take an argument of a profile name to open it directly.

But yes, it would be nice if at least one of these options were exposed in the UI so it was more discoverable by users.

Re:Beej's Quick Guide to GDB (2009) on Sunday November 05, 2023 @10:09PM (#38158347)
gf2 is worth looking at: https://github.com/nakst/gf
Re:Exploratory Data Analysis Using Awk on Friday October 06, 2023 @04:11PM (#37795680)
Something to watch out for with nl is that by default it doesn't number empty lines. e.g.:

  $ printf 'one\n\nthree\n' | nl
     1  one

     2  three
Set -ba to enable numbering all lines.

For this use case I usually end up running cat -n instead since I find it easier to remember.

Re:A Terminal Case of Linux on Tuesday May 30, 2023 @01:07PM (#36127447)
Your original command should work fine.

find does not pass arguments through an intermediate shell, so there are no quoting concerns with regard to spaces in filenames, etc.

And with the form of -exec terminated by a ; it runs a single command for each matching filesystem entry, so there will be no issues with exceeding the maximum argument size.

You can verify via strace:

  $ touch 'a b.md' 'c d.md'
  $ strace -fe execve find . -iname '*.md' -exec unbuffer ls {} \;
At the end of the exec chains you should see the following:

  execve("/bin/ls", ["ls", "./c d.md"] ...
  execve("/bin/ls", ["ls", "./a b.md"] ...
The filenames are being passed through spaces and all.

However if this were a real scenario, a better solution might be:

  find . -iname '*.md' -exec unbuffer ls -1 {} +
(Look up the -1 flag for ls, and the + variant of -exec for find for details)
Re:Teleforking a Process onto a Different Computer on Sunday April 26, 2020 @08:21PM (#22991644)
I did something similar using the 'at' daemon's 'now' time specification to "fork" off background tasks from a web request using the same .php file. It actually worked well for what I needed at the time!
Re:Tell HN: Toilet paper, hand sanitizer, and now web cams on Wednesday April 08, 2020 @02:17PM (#22815484)
Another plus of DroidCam is that it supports streaming the video over USB so no WiFi is necessary.