Quantcast
Channel: User Dennis Williamson - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 61

Answer by Dennis Williamson for Bash scripting rsync puzzler

$
0
0

Please see BashFAQ/050.

This fails because of WordSplitting and because the single quotes inside the variable are literal; not syntactical.

You should avoid putting commands in variables when shell scripting.

Use a function to be able to reuse a command. Use set -x for logging. Or use an array to hold the individual parts of the command and its arguments only if you must.

By the way, in one line you use $() for command substitution. This is the correct way. In another line you use backticks which is deprecated. At least be consistent.


Viewing all articles
Browse latest Browse all 61

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>