Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
I want to grep/extract some website immediately above a particular string

I want some specific websites to be extracted/grep before a string.

Example below:

Lets assume what is below is gibberish that i only want to extract website that is above SOLUTION NEEDED only! Not the other websites.

I only want to extract websites that can be found immediately above SOLUTION NEEDED

[36m[•] URL: abvfrt.com|LOAD
EXCEPTION: HTTPSConnectionPool(host='0.0.0.0', port=443): Read timed out. (read timeout=4)
[36m[•] URL: abc dot com |LOAD: xyz=345
EXCEPTION: HTTPSConnectionPool(host='0.0.0.0', port=443): Read timed out. (read timeout=4)
URL: Example dot com |: ABXCDRTTT
33m SOLUTION NEEDED
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can use grep -B n and -A n for showing you n number of lines Before or After the matched string.

In your case, something like

grep -B 1 "SOLUTION NEEDED" /path/to/file

about 4 years ago · Juan Pablo Isaza Relatório

0

Suggesting try this:

  grep -B1 "SOLUTION NEEDED" long.log | grep -oP "(?<=^URL: )[^|]*"

Explanations:

grep -B1 "SOLUTION NEEDED" long.log

Extract 1 line before each line matching "SOLUTION NEEDED"

grep -oP "(?<=^URL: )[^|]*"

From extracted lines. Extract URL value.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda