区切り記号は "";
入力する:
foo#foo_ehh113#The password of user 111 will expire within the next seven d
foo#foo_ehh204#The password of user 111 will expire within the next seven d
sadf#sadf this is a sample_text
foo#foo_ehh204#The password of user 222 will expire within the next seven da
foo - moreeee test
foo#foo_ehh113#The password of user 222 will expire within the next seven da
foo#foo_ehh113#The password of user 333 will expire within the next seven day
ldr#ldr_another sample text
foo#foo_ehh204#The password of user 333 will expire within the next seven day
出力:
foo#foo_ehh113#The password of user 111 will expire within the next seven d
foo#foo_ehh204#The password of user 111 will expire within the next seven d
foo#foo_ehh204#The password of user 222 will expire within the next seven da
foo#foo_ehh113#The password of user 222 will expire within the next seven da
foo#foo_ehh113#The password of user 333 will expire within the next seven day
foo#foo_ehh204#The password of user 333 will expire within the next seven day
たとえば、与えられた行に同様の単語があります。
The
password
of
user
will
expire
within
the
私の質問:どの程度似たような行だけを出力する方法はありますか?前任者。 8つの単語に一致します。
これを検出できるシェルスクリプトはありますか?
ベストアンサー1
テキストを順番に一致させるには、次のことを試すことができます。
$ grep 'The.*password.*of.*user.*will.*expire.*within.*the' file
foo#foo_ehh113#The password of user 111 will expire within the next seven d
foo#foo_ehh204#The password of user 111 will expire within the next seven d
foo#foo_ehh204#The password of user 222 will expire within the next seven da
foo#foo_ehh113#The password of user 222 will expire within the next seven da
foo#foo_ehh113#The password of user 333 will expire within the next seven day
foo#foo_ehh204#The password of user 333 will expire within the next seven day
テキストグループ(group.txtという名前)を含むファイルがある場合は、次のものを使用できます。
$ grep $(printf "%s.*" $(cat group.txt)) file