How to auto login in MySQL from a shell script?

Alternative ways to write these options. You can write mysql -u “$MYSQL_ROOT” -p”$MYSQL_PASS” -e “SHOW DATABASES” If [password is] given, there must be no space between –password= or -p and the password following it. If no password option is specified, the default is to send no password. to pass empty strings as separate arguments. Your … Read more

Extract filename and extension in Bash

First, get file name without the path: filename=$(basename — “$fullfile”) extension=”${filename##*.}” filename=”${filename%.*}” Alternatively, you can focus on the last “” of the path instead of the ‘.’ which should work even if you have unpredictable file extensions: filename=”${fullfile##*/}” You may want to check the documentation : On the web at section “3.5.3 Shell Parameter Expansion” … Read more