Показать полную графическую версию : Поиск grep-ом
blackeangel
25-11-2017, 13:26
Собственно, есть код
find /data | grep -v '/data/media'
Но при такой постановке из строк
/data/media
/data/media/folder/folder
/data/mediaservice
grep забирает все 3 строки, а надо лишь чтоб первые 2
Как быть?
CyberDaemon
03-12-2017, 16:58
-w, --word-regexp
Select only those lines containing matches that form whole words. The test is that the matching substring must either
be at the beginning of the line, or preceded by a non-word constituent character. Similarly, it must be either at the
end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and
the underscore.
find /data | grep -vw '/data/media'
/data/
/data/mediaservice
find /data | grep -v '/data/media' | head -n2
не уверен, что понял вопрос :)
DJ Mogarych
27-12-2017, 16:01
Добавить вторую команду
find /data/mediaservice
find /data | grep -v '/data/media[^/]\+'
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.