Does bash support word boundary regular expressions?

前端 未结 8 1647
面向向阳花
面向向阳花 2020-12-01 05:30

I am trying to match on the presence of a word in a list before adding that word again (to avoid duplicates). I am using bash 4.2.24 and am trying the below:



        
8条回答
  •  我在风中等你
    2020-12-01 06:00

    Not exactly "\b", but for me more readable (and portable) than the other suggestions:

    [[  $foo =~ (^| )myword($| ) ]]
    

提交回复
热议问题