\b in regular expressions match word boundaries (i.e. the location between the first word character and non-word character):
$ echo "bar embarassment" | sed "s/\bbar\b/no bar/g"
no bar embarassment
More Related Contents:
- Get lines between two patterns
- shell – remove numbers from a string column [closed]
- How to delete from a text file, all lines that contain a specific string?
- How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)?
- How to select lines between two marker patterns which may occur multiple times with awk/sed
- Find and replace in file and overwrite file doesn’t work, it empties the file
- Insert line after match using sed
- How to insert a newline in front of a pattern?
- Alternative to `sed -i` on Solaris
- Do a tail -F until matching a pattern
- How can I check the version of sed in OS X?
- Remove part of path on Unix
- Awk replace a column with its hash value
- Enhancement of unix script [closed]
- What’s the difference between .bashrc, .bash_profile, and .environment?
- How can I parse a YAML file from a Linux shell script?
- How to read a file into a variable in shell?
- Shell command to sum integers, one per line?
- Returning value from called function in a shell script
- Is there an Eclipse plugin to run system shell in the Console? [closed]
- How do you catch error codes in a shell pipe?
- How can I redirect the output of the “time” command?
- is it possible to use variables in remote ssh command?
- CMake’s execute_process and arbitrary shell scripts
- Sed to extract text between two strings
- Insert multiple lines into a file after specified pattern using shell script
- How to execute a shell script on a remote server using Ansible?
- How to grep a text file which contains some binary data?
- How to print 5 consecutive lines after a pattern in file using awk [duplicate]
- how do I use the grep –include option for multiple file types?