Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJess Claussen
6,078 PointsHow does grep know what file to look in when we do not specify a file?
Does its search limit to the current directory? would it search all the files in that directory? And could I use it to search files in another directory?
2 Answers
Ken Alger
Treehouse TeacherJess;
I guess I don't fully understand your question. When you don't pass grep a file name it "looks" for input elsewhere, for example from the standard input (keyboard) as is shown in the course video around the 2:05 time mark.
Is that what you are asking?
In terms of reading files in other directories, grep will search wherever you point it in the format:
$ grep (search term) (file name)
So, if you wanted to search for a file name
outside your current directory, you would just point it there.
Make any sense?
Ken
Pavlo Kochubei
15,009 PointsAt 2:40, the instructor types in the following:
$ grep hello
I guess, the first question was referring to this instance