How do I search a text file for a key-phrase or keyword and then print the line that key-phrase or keyword is in?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To print out multiple lines (in a simple way)
The comma in
print l,prevents extra spaces from appearing in the output; the trailing print statement demarcates results from different lines.Or better yet (stealing back from Mark Ransom):