-1

It is doing something to my path_bash variable but what?

Google pulls up this but I can't find it exactly.

#!/bin/bash

path_bash="$HOME/root/config/bash/"
source "${path_bash}_private.sh"
source "${path_bash}config.sh"
source "${path_bash}utility.sh"
source "${path_bash}workflow.sh"
source "${path_bash}net.sh"
source "${path_bash}makeHTM.sh"

and can I put

path_bash

in another file?

mikey balls
  • 115
  • 1
  • 7
  • 1
    As an aside, if you had `source "$path_bash/_private.sh"`, then you'd no longer need the curly braces, because the immediate next character would be something that couldn't be used in a variable name -- and you'd *also* be robust against the case where `path_bash` didn't have a trailing slash. – Charles Duffy Oct 23 '16 at 17:55
  • BTW, re: the links given you by Google, TLDP has a lot of Google juice, but their "Advanced" Bash Guide also has a reputation for showcasing bad practices and being only rarely updated. You're better off using either [the Wooledge BashGuide](http://mywiki.wooledge.org/BashGuide) or [the bash-hackers wiki](http://wiki.bash-hackers.org/), or of course [the official documentation](https://www.gnu.org/software/bash/manual/). – Charles Duffy Oct 23 '16 at 17:57

1 Answers1

4

It's used to tell bash where the name of your variable ends.

And example to explain:

$ a="gg"
$ echo $ab

$ echo ${a}b
ggb
user2314737
  • 27,088
  • 20
  • 102
  • 114
  • So in general I can put it around any variable? Also where is this in the documentation? – mikey balls Oct 23 '16 at 17:45
  • You can find it under "shell parameter expansion" https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html – user2314737 Oct 23 '16 at 17:47
  • 1
    Technically, `${a}` is the canonical way to perform parameter expansion. The braces can be optionally (and typically are) dropped when no parameter expansion operators are used and the name of the variable can be unambiguously determined. – chepner Oct 23 '16 at 20:35