Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I grep out a particular line from a file in a folder.

Basically I have a folder /my/cool/folder/myfile.txt

I know it has line: I am cool lkasjdfaksldfj

How can I grep on that file so the line starting with I am cool .... shows on the terminal?

share|improve this question
add comment

3 Answers

up vote 8 down vote accepted
$ grep "^I am cool lkasjdfaksldfj" /my/cool/folder/myfile.txt

Also:

$ man grep

It'll do ya good.

share|improve this answer
add comment

grep "^I am cool lkasjdfaksldfj" /my/cool/folder/myfile.txt

If you want to search in all files in a folder

grep "^I am cool lkasjdfaksldfj" /my/cool/folder/*

If you want the string to be searched anywhere and not necessarily the beginning of line

grep "I am cool lkasjdfaksldfj" /my/cool/folder/myfile.txt

share|improve this answer
add comment

also

$ cat myfile | grep mytext

in order to output to the terminal

share|improve this answer
3  
Useless use of cat. –  Teddy Mar 26 '10 at 8:41
    
Why limit yourself to a single process when you can use two?!?! ;) –  EEAA Mar 26 '10 at 14:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.