Is there a “standard” format for command line/shell help text?

Typically, your help output should include: Description of what the app does Usage syntax, which: Uses [options] to indicate where the options go arg_name for a required, singular arg [arg_name] for an optional, singular arg arg_name… for a required arg of which there can be many (this is rare) [arg_name…] for an arg for which … Read more

Check if a file exists with a wildcard in a shell script [duplicate]

For Bash scripts, the most direct and performant approach is: if compgen -G “${PROJECT_DIR}/*.png” > /dev/null; then echo “pattern exists!” fi This will work very speedily even in directories with millions of files and does not involve a new subshell. Source The simplest should be to rely on ls return value (it returns non-zero when … Read more

How do I set tmux to open specified windows at startup?

You can write a small shell script that launches tmux with the required programs. I have the following in a shell script that I call dev-tmux. A dev environment: #!/bin/sh tmux new-session -d ‘vim’ tmux split-window -v ‘ipython’ tmux split-window -h tmux new-window ‘mutt’ tmux -2 attach-session -d So everytime I want to launch my … Read more

What is /dev/null 2>&1?

>> /dev/null redirects standard output (stdout) to /dev/null, which discards it. (The >> seems sort of superfluous, since >> means append while > means truncate and write, and either appending to or writing to /dev/null has the same net effect. I usually just use > for that reason.) 2>&1 redirects standard error (2) to standard … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)