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

308
Views
Adding additional newline between each line

I am analyzing log files from my server(particular few lines from there). But those lines are having around 1000 to 2000 characters in length.

Here is an example how the lines are coming out with grep and less with following command.

tail -n 1000 log.log | grep 'SOME_TEXT' | less

Output:

random text SOME_TEXT another 1000 chars
random SOME_TEXT 2000 chars
text text SOME_TEXT 2000 chars

But its hard for me to separate them as those are screen full of texts(also not pleasant for eyes either). I want to have my output like blow:

random text SOME_TEXT another 1000 chars

random SOME_TEXT 2000 chars

text text SOME_TEXT 2000 chars

And I have modified my above command with sed:

tail -n 1000 log.log | grep 'SOME_TEXT' | sed 's/\n/\n\n/' | less

It didn't work, so I tried with tr next:

tail -n 1000 log.log | grep 'SOME_TEXT' | tr '\n' '\n\n' | less

It didn't work with me either. What am I missing here?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

This might work for you:

sed G file
over 4 years ago · Santiago Trujillo Report

0

This will search for pattern and print only pattern with an extra blank line after it.

awk '/SOME_TEXT/ {print $0 RS}' file

Example:

cat file
test
more
SOME_TEXT my data
more
even more
SOME_TEXT need more
more data
yes

awk '/SOME_TEXT/ {print $0 RS}' file
SOME_TEXT my data

SOME_TEXT need more

To print all text, with a blank line after pattern

awk '8; /SOME_TEXT/ {print ""}' file
test
more
SOME_TEXT my data

more
even more
SOME_TEXT need more

more data
yes
over 4 years ago · Santiago Trujillo Report

0

You can try this sed,

sed '/SOME_TEXT/s/.*/&\n/g' logfile.log

Or

sed '/SOME_TEXT/G' logfile.log
over 4 years ago · Santiago Trujillo 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!