![]() (PS: I know most platforms by now would have been patched for \w. Ultimately, the POSIX answer above will be a lot more reliable regardless of platform (being the original) for grepĪs for support of grep without -o option, the first grep outputs the relevant lines, the tr splits the spaces to new lines, the final grep filters only for the respective lines. See the Wikipedia page on regular expression for more As such, those grep installations that are limited to work with POSIX character classes use ] and not its perl equivalent of \w. The usage of \w varies from platform to platform, as it's an extended "perl" syntax. The reason why the original answer does not work for everyone ![]() w The expression is searched for as a word (as if surrounded by More from the manual for grep -o Print each match, but only the match, not the entire line. What word or regular expression you would be searching for then, is up to you! As long as you remain with POSIX and not perl syntax (refer below) To summarize: -oh outputs the regular expression matches to the file content (and not its filename), just like how you would expect a regular expression to work in vim/etc. Expectation when I do a regex grep : So mail
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |