br comando não funciona com a cadeia de pesquisa [duplicada]

1

Eu tenho um arquivo de log que se parece com o seguinte:

2017-05-30 23:11:34,429 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:34,438 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:34,438 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking auth agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:34,453 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - SSH: Failed login attempt on [172.16.8.1]. Username: "rene1".
2017-05-30 23:11:33,673 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking logout agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:33,682 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Logout agent success [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:33,819 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.KeyboardInteractiveAuthentication - SSH: Sent SSH_MSG_USERAUTH_INFO_REQUEST (Password Authentication): 
2017-05-30 23:11:33,871 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - User login attempt has been made from address /172.16.8.1:54626
2017-05-30 23:11:32,042 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:32,072 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:31,072 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:31,090 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:31,091 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking auth agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:31,095 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - SSH: Failed login attempt on [172.16.8.1]. Username: "rene1".
2017-05-30 23:11:30,429 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:30,429 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:30,438 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:30,438 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking auth agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:30,453 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - SSH: Failed login attempt on [172.16.8.1]. Username: "rene1".
2017-05-30 23:11:30,429 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:26,429 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:26,438 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:20,438 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking auth agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:20,453 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - SSH: Failed login attempt on [172.16.8.1]. Username: "rene1".
2017-05-30 23:11:18,673 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking logout agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:18,682 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Logout agent success [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:15,819 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.KeyboardInteractiveAuthentication - SSH: Sent SSH_MSG_USERAUTH_INFO_REQUEST (Password Authentication): 
2017-05-30 23:11:15,871 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - User login attempt has been made from address /172.16.8.1:54626
2017-05-30 23:11:14,042 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:14,072 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:12,072 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:11,090 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:10,091 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking auth agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:09,095 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - SSH: Failed login attempt on [172.16.8.1]. Username: "rene1".
2017-05-30 23:11:09,415 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - User login attempt has been made from address gateway/172.16.8.1:54626
2017-05-30 23:10:59,416 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:10:42,429 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:10:35,429 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:10:30,438 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]



Gostaria de pesquisar o arquivo de log usando sed para minha cadeia de caracteres de pesquisa inicial em Invoking logout agent até a string de pesquisa final ser Failed login attempt . Se corresponder aos critérios, ele retornará as informações entre essas strings de pesquisa. Portanto, pode haver vários critérios correspondentes retornados, já que podem ser impressos em outro local do log. Mas eu não consigo fazer funcionar como esperado, mas é um trabalho com intervalo de tempo onde eu tinha usado antes. Esta é a minha sed e argumentos obrigatórios

sed -n '/Invoking logout agent/,/Failed login attempt/p' 1min.txt



Parece que me retorna um pedaço inteiro do arquivo de log porque a primeira linha de informações retornadas não tem " Invoking logout agent ". De lá, eu posso saber que não está funcionando corretamente. Posso saber qual é o meu problema? Este é o pedaço de log que eu mais preciso

2017-05-30 23:11:33,673 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking logout agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:33,682 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Logout agent success [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:33,819 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.KeyboardInteractiveAuthentication - SSH: Sent SSH_MSG_USERAUTH_INFO_REQUEST (Password Authentication): 
2017-05-30 23:11:33,871 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - User login attempt has been made from address /172.16.8.1:54626
2017-05-30 23:11:32,042 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:32,072 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:31,072 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:31,090 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:31,091 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking auth agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:31,095 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - SSH: Failed login attempt on [172.16.8.1]. Username: "rene1".
    
por attack 02.06.2017 / 07:43

1 resposta

1

sed solução:

sed -n '/Invoking logout agent/{:a;N;/Failed login attempt/!ba;G;p;}' imin.txt

A saída:

2017-05-30 23:11:33,673 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking logout agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:33,682 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Logout agent success [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:33,819 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.KeyboardInteractiveAuthentication - SSH: Sent SSH_MSG_USERAUTH_INFO_REQUEST (Password Authentication): 
2017-05-30 23:11:33,871 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - User login attempt has been made from address /172.16.8.1:54626
2017-05-30 23:11:32,042 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:32,072 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:31,072 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:31,090 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:31,091 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking auth agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:31,095 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - SSH: Failed login attempt on [172.16.8.1]. Username: "rene1".

2017-05-30 23:11:18,673 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking logout agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:18,682 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Logout agent success [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:15,819 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.KeyboardInteractiveAuthentication - SSH: Sent SSH_MSG_USERAUTH_INFO_REQUEST (Password Authentication): 
2017-05-30 23:11:15,871 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - User login attempt has been made from address /172.16.8.1:54626
2017-05-30 23:11:14,042 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:14,072 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:12,072 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking config agent [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:11,090 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Config agent success [accountName=rene1 remoteAddress=gateway/172.16.8.1]
2017-05-30 23:11:10,091 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - Invoking auth agent [accountName=rene1 remoteAddress=STEDGE/172.16.8.3]
2017-05-30 23:11:09,095 INFO [SSHD-TRANSFER-1] com.tumbleweed.st.server.sshd.AuthenticationProviderImpl - SSH: Failed login attempt on [172.16.8.1]. Username: "rene1".

Detalhes :

  • /Invoking logout agent/ - em cada linha de encontro com Invoking logout agent

  • :a; - define rótulo a

  • N; - acrescente a próxima linha ao espaço padrão

  • /Failed login attempt/!ba; - a menos que o espaço padrão contenha Failed login attempt - retorne ao marcador a

  • G - acrescente nova linha após cada conteúdo correspondente para facilitar a leitura

  • p - imprima o espaço padrão

por 02.06.2017 / 08:37

Tags