TierOne
TierOne

Reputation: 71

Use grep to find the words that have two 's' separated by a space

I'm trying to use grep to find the words that have two 's' separated by a space, then two 's' or more in the words, and then the words that contain exactly two 's'.

I already tried these commands

ls|grep -E 's+'

ls|grep -E 's+'|grep \s

ls|grep -E s{2,\}

The two first commands print all the words that contains 1 's' or more, that isn't what I'm looking for, and the last command prints all the words that contain two 's' side by side ...

Btw, I'm also having trouble to find the exact same output of "grep -c", without the "-c" argument ...

For example ls -R| grep s prints 14k approximately, and I want to find the same result, without -c

Thanks in advance

Upvotes: 2

Views: 1532

Answers (1)

Ipor Sircer
Ipor Sircer

Reputation: 3141

grep "s s"
grep "s.*s"
grep -E "^[^s]*s[^s]*s[^s]*$"

Upvotes: 2

Related Questions