使用 grep 查找两个 's' 以空格分隔的单词 [英] Use grep to find the words that have two 's' separated by a space

查看:26
本文介绍了使用 grep 查找两个 's' 以空格分隔的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 grep 查找具有两个以空格分隔的 's' 的单词,然后是单词中的两个 's' 或更多,然后是正好包含两个 's' 的单词.

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'.

我已经尝试过这些命令

ls|grep -E 's+'

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

ls|grep -E s{2,}

前两个命令打印所有包含 1 's' 或更多的单词,这不是我要找的,最后一个命令打印所有包含两个 's' 的单词并排...

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 ...

顺便说一句,我也很难找到与grep -c"完全相同的输出,而没有-c"参数......

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

例如 ls -R|grep s 大约打印 14k,我想找到相同的结果,没有 -c

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

提前致谢

推荐答案

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

这篇关于使用 grep 查找两个 's' 以空格分隔的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆