Skip to main content
edited tags
Link
don_crissti
  • 85.6k
  • 31
  • 234
  • 262
Tweeted twitter.com/StackUnix/status/700890633028947970
edited title
Source Link
jevan
  • 41
  • 1
  • 5

I need to find a string and need to print the line above it.


case1: The same line won't have the more than one matching pattern

ie) consider a file containing

$cat > para
returns between the paragaraphs
italic or bold    
quotes by placing
italic

Here i need to find for italic, and i need to get the output as below

returns between the paragaraphs
quotes by placing

How can i get the output like this?

I need to find a string and need to print the line above it.

ie) consider a file containing

$cat > para
returns between the paragaraphs
italic or bold    
quotes by placing
italic

Here i need to find for italic, and i need to get the output as below

returns between the paragaraphs
quotes by placing

How can i get the output like this?

I need to find a string and need to print the line above it.


case1: The same line won't have the more than one matching pattern

ie) consider a file containing

$cat > para
returns between the paragaraphs
italic or bold    
quotes by placing
italic

Here i need to find for italic, and i need to get the output as below

returns between the paragaraphs
quotes by placing

How can i get the output like this?

edited title
Link
jevan
  • 41
  • 1
  • 5

Find each line matching a pattern but print only the line above it....

deleted 47 characters in body; edited tags; edited title
Source Link
don_crissti
  • 85.6k
  • 31
  • 234
  • 262
Loading
deleted 572 characters in body; edited title
Source Link
jevan
  • 41
  • 1
  • 5
Loading
Fixed-width formatting, relevant tags
Source Link
Michael Homer
  • 78.9k
  • 17
  • 221
  • 239
Loading
Source Link
jevan
  • 41
  • 1
  • 5
Loading