LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-04-2013, 09:51 PM   #1
313
Member
 
Registered: Oct 2011
Location: Cardiff
Distribution: Debian 6.0.5
Posts: 39

Rep: Reputation: Disabled
Printing lines starting from specific text.


How can I print all lines from a file after a specific bit of text? I've tried googling but I came up with nothing.

Essentially I have music information files that list personnel after "psn;" and want to print everything following that.

I've tried
Code:
cat /path/file.txt | grep psn;
But that only prints the line with "psn;" on.

Thanks in advance.

Last edited by 313; 09-05-2013 at 07:14 AM.
 
Old 09-04-2013, 11:49 PM   #2
eklavya
Member
 
Registered: Mar 2013
Posts: 619

Rep: Reputation: 136Reputation: 136
If you want that line should be started where psn comes last, try this.
Code:
grep "psn" /path/of/file.txt | sed 's/.* psn/psn/g'
Now where psn will come last time in the line it shows complete line from where.
I am considering that there is space before psn

Last edited by eklavya; 09-05-2013 at 12:11 AM.
 
2 members found this post helpful.
Old 09-05-2013, 01:30 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,452

Rep: Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776
Try this:
awk '/psn;/{a++}a' <input file>
 
1 members found this post helpful.
Old 09-05-2013, 07:14 AM   #4
313
Member
 
Registered: Oct 2011
Location: Cardiff
Distribution: Debian 6.0.5
Posts: 39

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
Try this:
awk '/psn;/{a++}a' <input file>
Perfect, thank you very much.
 
Old 09-05-2013, 07:15 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,452

Rep: Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776Reputation: 2776
glad to help you. if you really want to say thanks just press yes.
 
Old 09-05-2013, 10:28 AM   #6
313
Member
 
Registered: Oct 2011
Location: Cardiff
Distribution: Debian 6.0.5
Posts: 39

Original Poster
Rep: Reputation: Disabled
Have done.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Join two specific lines in a text file bfay General 2 03-02-2013 07:41 PM
matching and printing specific lines iconig Linux - Newbie 1 08-23-2012 01:02 PM
Printing $ Lines After Finding Specific Pattern pravin.bhande Programming 6 04-12-2012 10:20 AM
Printing specific lines of a file using script. barunparichha Linux - Software 6 05-20-2009 12:31 AM
Read specific lines from a text file chobin Programming 8 06-14-2006 11:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration