\n'/} ...">

What does this BASH shell script snippet do?

Can you explain the following code (assume the HOST contains a string):

HOST=${HOST//$'\n'/}

      

If the above line was declared inside a function, would the "HOST" variable be available to other functions in the same script?

+3


source to share


1 answer


As per the Substring Replacement subtitle from the ABS manual :

HOST=${HOST//$'\n'/}

      

removes all occurrences of the newline character $'\n'

in the variable HOST

.



If the above line was declared inside a function, would the variable be HOST

available to other functions in the same script?

Yes, assuming it was HOST

not declared using bash local

.

+9


source







All Articles