Comment

Comment by mhd

Knew most of those, not much interested in "shell plugins".

One thing that many people miss are parameter expansions. Those are in Posix, so pretty much any bare shell should be able to use that, too. So dash/bash/zsh/ksh…

    echo Hello ${PLANET:-World} 
to have a default if you're not sure a variable is set. Replace "-" with "=" to actually set it, not just use it for this statement.

Or removing suffixes:

    filename=/tmp/foobar.tar.gz
    echo ${filename%.*} # -> /tmp/foobar.tar
    echo ${filename%%.*} # -> /tmp/foobar
Saves you some useless sed/awk.

I still wish the Linux shells (bash/zsh) would start to finally get some more features from friggin' ksh93.

parent mhd 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton