Alberto
Alberto

Reputation: 359

How to indicate a search directory different than the current one in grep

How do I run a grep on the "c:\Test" directory from "c:\Users\myName? I tried with grep c:\Test text -r but it doesn't work.

Thank you

Upvotes: 0

Views: 16

Answers (1)

CyberStems
CyberStems

Reputation: 358

You need to include the string that you would like to grep in your command then the file, the syntax for grep is grep <string> <file path>

lets say I'm in the home directory that contains a sub-directory called test with a couple text files inside it:

file1.txt: hello world
file2.txt: the quick brown fox had entered the world

etc...

if I was grepping the word "world" from the home directory I would type this

grep world test/*

the "*" character just means search all files.

Upvotes: 2

Related Questions