What does — do when running an npm command?

— as an argument on its own is standardized across all UNIX commands: It means that further arguments should be treated as positional arguments, not options. See Guideline 10 in POSIX Utility Syntax Conventions. To give you a non-NPM-based example, ls — -l will look for a file named -l, because the — specified that … Read more

How to get bc to handle numbers in scientific (aka exponential) notation?

Unfortunately, bc doesn’t support scientific notation. However, it can be translated into a format that bc can handle, using extended regex as per POSIX in sed: sed -E ‘s/([+-]?[0-9.]+)[eE]\+?(-?)([0-9]+)/(\1*10^\2\3)/g’ <<<“$value” you can replace the “e” (or “e+”, if the exponent is positive) with “*10^”, which bc will promptly understand. This works even if the exponent … Read more

How to zero pad numbers in file names in Bash?

It’s not pure bash, but much easier with the Perl version of rename: rename ‘s/\d+/sprintf(“%05d”,$&)/e’ foo* Where ‘s/\d+/sprintf(“%05d”,$&)/e’ is the Perl replace regular expression. \d+ will match the first set of numbers (at least one number) sprintf(“%05d”,$&) will pass the matched numbers to Perl’s sprintf, and %05d will pad to five digits

tech