Tuesday, 15 February 2011

bash - How can I print out all lines of a file containing a specific String in unix -


I know how to print the line of the first occurrence of the string, but I'm not sure how to print Events have to do To print the first occurrence of my string I have used

  grep ", 1," my_course   

I think all events Something looks like print:

  while grep (the next line of the file), 1, "my_course   

I'm not sure how to To do this while loop though. How can I test if the file is the next line.

EDIT: Sorry, I think grep only matches the first event. When I ran away, it only corresponds to 1 line. I did not know that only 1 line matched

In addition to this, the bonus question is if someone wants to answer ... if all the lines in my file (Mycorsy) "number, name, Credit hours, grades ", how do I get all the grades in the file and store it in an array?

grep <

grep, egrep, fgrep - Print lines match a pattern

/ P>

No comments:

Post a Comment