LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Printing lines starting from specific text. (https://www.linuxquestions.org/questions/linux-newbie-8/printing-lines-starting-from-specific-text-4175475970/)

313 09-04-2013 09:51 PM

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.

eklavya 09-04-2013 11:49 PM

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

pan64 09-05-2013 01:30 AM

Try this:
awk '/psn;/{a++}a' <input file>

313 09-05-2013 07:14 AM

Quote:

Originally Posted by pan64 (Post 5022076)
Try this:
awk '/psn;/{a++}a' <input file>

Perfect, thank you very much.

pan64 09-05-2013 07:15 AM

glad to help you. if you really want to say thanks just press yes.

313 09-05-2013 10:28 AM

Have done.


All times are GMT -5. The time now is 07:54 PM.