Using SED with wildcard

The asterisk (*) means “zero or more of the previous item”. If you want to match any single character use If you want to match any string (i.e. any single character zero or more times) use

Multi-dimensional arrays in Bash

Bash does not support multidimensional arrays, nor hashes, and it seems that you want a hash that values are arrays. This solution is not very beautiful, a solution with an xml file should be better : EDIT: this answer is quite old, since since bash 4 supports hash tables, see also this answer for a solution without … Read more

Speed up rsync with Simultaneous/Concurrent File Transfers?

Updated answer (Jan 2020) xargs is now the recommended tool to achieve parallel execution. It’s pre-installed almost everywhere. For running multiple rsync tasks the command would be: This will list all folders in /srv/mail, pipe them to xargs, which will read them one-by-one and and run 4 rsync processes at a time. The % char replaces the input argument for each command call. Original … Read more

How do I automatically restart a Minecraft Spigot server in the event of a crash or /stop when using screen?

Tutorial A friend wrote a bash script to automatically restart a minecraft (spigot) server in the event of a crash or with the command “/stop” when using screen. There are several seconds to cancel the restart with Enter. In addition, the exit codes of the previous session are written to a file, which can be … Read more

choosing between $0 and BASH_SOURCE

Note: For a POSIX-compliant solution, see this answer. ${BASH_SOURCE[0]} (or, more simply, $BASH_SOURCE[1] ) contains the (potentially relative) path of the containing script in all invocation scenarios, notably also when the script is sourced, which is not true for $0. Furthermore, as Charles Duffy points out, $0 can be set to an arbitrary value by the caller.On the flip side, $BASH_SOURCE can be empty, if no named file is involved; e.g.:echo ‘echo “[$BASH_SOURCE]”‘ | … Read more

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