I'm trying to understand sed. I have to replace every word starting with an a or A in a lipsum.txt with the word foobar. I started with cat lipsum.txt | sed 's/\ba/foobar/g'
which already works, but it only replaces the a and not the entire word.
I read about using cat lipsum.txt | sed 's/\ba\w+/foobar/g'
which targets the entire word. But it just doesn't replace anything. Same with cat lipsum.txt | sed 's/\ba[A-Z]*/foobar/g'
, it just leaves the text untouched. What am I doing wrong?
同样,如果我将a替换为“(a | A)”不区分大小写,它也会停止工作。