I have a file that has a story contained in it, and I need to practice using either grep or sed. I have tried
egrep -i '^w.' file.txt and it gets most of the words, but I need every word starting with w ("Paperwork" is invalid, "working" is valid).
Probably you'd need a regexp to isolate word start (
\b) and recognize word characters, e.g.
\S, see documentation for more. So you could use the command
$ grep -oE '\bw\S*' inputfile
-o, the result will be only the matching parts, with each match on a new line (even from the one input line), and
-E to be able to use "extended regex" (the same as using
A more strict "word" match might use
[[:alpha:]] instead of
$ grep -oE '\bw[[:alpha:]]*' inputfile
That would result in "words" (character sequences) in the English character set, starting with "w".