1

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?

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

Also:

$ man grep

It'll do ya good.

0

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

-3

also

$ cat myfile | grep mytext

in order to output to the terminal

2
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy