Reputation: 756
Can you explain the following code please (assume that HOST contains a string):
HOST=${HOST//$'\n'/}
If the above line was declared inside a function, would the variable "HOST" be available to other functions in the same script?
Upvotes: 3
Views: 188
Reputation: 5305
According to Substring Replacement subchapter from the ABS guide:
HOST=${HOST//$'\n'/}
removes all occurrences of the newline character $'\n'
in the HOST
variable.
If the above line was declared inside a function, would the variable
HOST
be available to other functions in the same script?
Yes, assuming HOST
wasn't declared using bash local
keyword.
Upvotes: 9