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?

3 Answers3

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

Also:

$ man grep

It'll do ya good.

EEAA
  • 109,363
  • 18
  • 175
  • 245
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

Goats
  • 17
  • 4