regex - Grep unknown number of spaces (linux) -


suppose have file named abc.txt - file contains 2 (or more) lines:

word  -c           (09:35:20) word     -c        (09:38:49) 

if run command $ grep "word -c" abc.txt 1st line, because number of spaces between 1 , -c not match 2nd line. there way fix problem?

you cannot use grep'word1|word2' /path/to/file spaces between word , -c vary.

use + regex character, match @ least 1 of preceding character:

grep -e "word +-c" abc.txt 

this regex reads "match 'word', followed 1 or more spaces, followed '-c'."


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -