Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!