String replacement in bash - bad substitution error

前端 未结 2 1308
生来不讨喜
生来不讨喜 2020-12-09 12:04

I newbie in bash scripting but i don\'t uderstand why it\'s not work

#!/bin/bash
foo=foobarfoobar
echo ${foo//bar/baz}

bad substitution err

2条回答
  •  一向
    一向 (楼主)
    2020-12-09 12:27

    $ foo=foobarfoobar
    $ echo ${foo}/bar/baz
    foobarfoobar/bar/baz
    

    Just that you have the braces in the wrong place, but then I am no expert at BASH, so perhaps this isn't the effect you're going for..

提交回复
热议问题