The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need to cut a part of a XML file elbombillo Shell Programming and Scripting 9 12-10-2008 10:41 PM
comparing part of header with part of detailed records. cmaroju Shell Programming and Scripting 1 12-02-2008 04:45 AM
cut a part of the file kurosaki Shell Programming and Scripting 1 06-02-2008 09:14 AM
How to extract certain part of log file? superHonda123 Shell Programming and Scripting 10 05-24-2008 12:56 PM
Help with multiple file rename - change case of part of file name steve7 UNIX for Dummies Questions & Answers 7 06-30-2005 01:41 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 1 Week Ago
OneDreamCloser OneDreamCloser is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 10
Keep just a part of a file ...

hello all,

i would like your help on the following :

GIVEN a text file with the following format :
Code:
a
b
c
d
===============================================================
e
HOW can i delete all the lines that are located above this line (namely a, b, c, d lines) :
Code:
===============================================================
OR just keep the line with the equal signs and the line e ?

the desired output would be :
Code:
===============================================================
e
thank you
  #2 (permalink)  
Old 1 Week Ago
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,033
Quote:
Originally Posted by OneDreamCloser View Post
hello all,

i would like your help on the following :

GIVEN a text file with the following format :
Code:
a
b
c
d
===============================================================
e
HOW can i delete all the lines that are located above this line (namely a, b, c, d lines) :
Code:
===============================================================
OR just keep the line with the equal signs and the line e ?

the desired output would be :
Code:
===============================================================
e
thank you

Code:
awk '/=/{P=1}P' file1
(or)
Code:
awk '/^=+$/{P=1}P' file1
  #3 (permalink)  
Old 1 Week Ago
thegeek thegeek is online now
Registered User
  
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 434
Code:
cat > t1
a
b
c
d
===============================================================
e
Code:
sed -n '/=/,$p' t1
===============================================================
e
  #4 (permalink)  
Old 1 Week Ago
OneDreamCloser OneDreamCloser is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 10
thank you guys !

in the case that i would like to delete all the text that appears before the pattern :
Code:
a
b
c
===============================================================
======================== RESULTS ==============================
===============================================================
d
e
how i could do that ?
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0