How do I sleep for a millisecond in bash or ksh

Bash has a “loadable” sleep which supports fractional seconds, and eliminates overheads of an external command: $ cd bash-3.2.48/examples/loadables $ make sleep && mv sleep sleep.so $ enable -f sleep.so sleep Then: $ which sleep /usr/bin/sleep $ builtin sleep sleep: usage: sleep seconds[.fraction] $ time (for f in `seq 1 10`; do builtin sleep 0.1; … Read more

How to mkdir only if a directory does not already exist?

Try mkdir -p: Note that this will also create any intermediate directories that don’t exist; for instance, will create directories foo, foo/bar, and foo/bar/baz if they don’t exist. Some implementation like GNU mkdir include mkdir –parents as a more readable alias, but this is not specified in POSIX/Single Unix Specification and not available on many common platforms like macOS, various BSDs, and various commercial … Read more

How to mkdir only if a directory does not already exist?

Try mkdir -p: Note that this will also create any intermediate directories that don’t exist; for instance, will create directories foo, foo/bar, and foo/bar/baz if they don’t exist. Some implementation like GNU mkdir include mkdir –parents as a more readable alias, but this is not specified in POSIX/Single Unix Specification and not available on many common platforms like macOS, various BSDs, and various commercial … Read more