# Tag Info

2

[ x == y ] is not strictly-conforming POSIX sh. Use [ x = y ] instead. Instead of using /home/MyName, you may consider using the environment variable ${HOME}. I think you made a typo in "$ filename". Use "$filename" instead. Good job on the commenting and indentation. 2 Here are my thoughts, in no particular order of importance: Use parameter validation and script parameters, they are stupidly convenient in powershell, for example, put this at the very top of the script: param( [Parameter] [ValidateSet('Start','Stop')} # Can have more than two possible values of course [string]$mode ) The error message from ...

0

Note: a module is actually a directory located in some "wp-content/plugins" directories. Study case Your shell command is incorrect, inefficient and unnecessarily convoluted. for i in $(find . -type d -name 'plugins' | grep 'wp-content/plugins$'); do find $i -maxdepth 1 -type d -exec sh -c 'for f do basename -- "$f"; done' sh {} + ; done | sort -u The ...

3

If plugins only contain directories, list every unique entry in plugins: shopt -s extglob \ls -- **/wp-content/plugins |sort -u Otherwise, include the final targets in the glob, plus a trailing slash to limit globbing to directories. That will yield paths relative to ., with trailing slash like siteA/wp-content/plugins/anotherplugin/. We clean it up ...

1

Just maybe rsync for remote synchronisation might be attractive. rsync --dryrun ...

0

I don't think you need the temporary file, if you open for append (i.e. >>), and use comm to find the non-duplicate lines (after sorting).

4

There's nothing here that requires Bash rather than standard (POSIX) shell, so we can use #!/bin/sh However, don't do that, because we can use a Bash feature to avoid exposing the plaintext password to other users (see below). I recommend making the shell exit if we attempt to expand any unset variables, or if any of the programs we run exits with an ...

3

Try to avoid using echo in your bash script; use printf instead (why? look here): hashed=$(printf "%s" "$GUAC_PASSWORD" | sha256sum | cut -f1 -d\ ) Note also the uppercase variable in bash script are for environment variables; use lowercase ones (ref). At last, do not use <<< in your case because it adds a newline and won't output the same hash ...

6

If GUAC_PASSWORD is a string like -e foo or /etc/*, that's going to create problems. Quote the input and avoid echo altogether. While you're at it, whitelist the checksum output, making head redundant: HASHED=$( tr -d '\n' <<<"$GUAC_PASSWORD" | sha256sum | tr -dc a-f0-9 ) edit: suppress newline added by <<<

3

Commandline Syntax You seem to be using the POSIX and GNU command line syntax, allowing both short as long options: "-f" | "--javafx" But the most important one "help" is only accessible through: "--help" I would be consistent and use: "-h" | "--help" | "-?" Also note that the question mark is a universal identifier for the help command. You may ...

2

Use sort's -u and -o switches: find … | sort -u - $file -o$file

1

I like the script. But I have maybe some suggestions for improvement. This part: RAM=$(free -m) total=$(echo "$RAM"|awk '/^[mM]em\.?:/{print$2}') available=$(echo "$RAM"|awk '/^[mM]em\.?:/{print $7}') Personalty I prefer to dig these values from /proc/meminfo to avoid running unnecessary free utility, but I saw several scripts based on it. And in case ... 3 Naming Try not to use generic names like$file. Make your code read easy for others. Say $files_to_backup for example. Check for errors when it matters If backup is important: check that the backups succeeded: if cp "${files[@]}"${war}/mediawiki_specific_backups";then rm -rf "${war}/${domain}" mkdir "${war}/\${domain}" ... ... else #...

Top 50 recent answers are included