文字列の一部を置き換えする(sed)
#!/bin/sh #str_replace.sh text="The quick brown fox jumps over the lazy fox." echo $text | sed 's/fox/DOG/' echo $text | sed 's/fox/DOG/g' #oで始まる単語をafterに変更する echo $text | sed 's/\<o[^ ]*/after/'
$ ./str_replace.sh The quick brown DOG jumps over the lazy fox. The quick brown DOG jumps over the lazy DOG. The quick brown fox jumps after the lazy fox.