In order from worst to best: DIRNAME="$(dirname $FILE)" will not do what you want if $FILE contains whitespace or globbing characters \[?*. DIRNAME=`dirname "$FILE"` is technically correct, but backticks are not recommended for command expansion because of the extra quoting issues when nesting them. DIRNAME=$(dirname "$FILE") is correct, but only because this is an assignment. If you use the command substitution in any other context, such as export DIRNAME=$(dirname "$FILE") or du $(dirname "$FILE"), the lack of quotes will cause trouble if the result of the expansion contain whitespace or globbing characters. DIRNAME="$(dirname "$FILE")" is the recommended way. You can replace DIRNAME= with a command and a space without changing anything else, and dirname receives the correct string. To improve even further: DIRNAME="$(dirname -- "$FILE")" works if $FILE starts with a dash. DIRNAME="$(dirname -- "$FILE"; printf x)" && DIRNAME="${DIRNAME%?x}" works even if $FILE ends with a newline, since $() chops off newlines at the end of output and dirname outputs a newline after the result. You can nest command expansions as much as you like. With $() you always create a new quoting context, so you can do things like this: foo "$(bar "$(baz "$(ban "bla")")")" You do not want to try that with backticks.
Title | Time |
---|---|
Ryan Garner - Archie Shar... | 4 minutes |
France vs Guinea Live Str... | 10 minutes |
sdbsdbsdbdsbdbs | 12 minutes |
Live streaming France - G... | 12 minutes |
Watch Errani - Zheng Live... | 16 minutes |
Live streaming Errani v Z... | 22 minutes |
Living Wellness Day Spa | 36 minutes |
© Paste4BTC 2014 - Earn bitcoins by pasting! | My pastes | Popular pastes | New pastes | Payments | FAQ | Terms of Service