Sign up ×
Server Fault is a question and answer site for 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

3 Answers 3

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


$ man grep

It'll do ya good.

share|improve this answer

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


$ cat myfile | grep mytext

in order to output to the terminal

share|improve this answer
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

Your Answer


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