 |
 |
Grep on seeming to work...
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2002
Location: Hilton Head, SC
Status:
Offline
|
|
I was trying to use the grep function this morning and it seemed to just hang there... the command I used was: grep -i finder
not sure what happened... am I doing this correctly?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
Originally posted by Tyler McAdams:
I was trying to use the grep function this morning and it seemed to just hang there... the command I used was: grep -i finder
not sure what happened... am I doing this correctly?
The pattern for grep is
Yoy passed "grep pattern" but did not specify a file, so it was trying to grep standard input.
Try something like "grep -i finder *"
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2002
Location: Hilton Head, SC
Status:
Offline
|
|
Originally posted by Arkham_c:
The pattern for grep is
Yoy passed "grep pattern" but did not specify a file, so it was trying to grep standard input.
Try something like "grep -i finder *"
So i need a space and an astric after the file name I'm trying to find?
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Dec 2001
Status:
Offline
|
|
Originally posted by Tyler McAdams:
So i need a space and an astric after the file name I'm trying to find?
grep doesn't search for file names, it searches the contents of files. The asteric is a shell "glob" character which basically says "match all file names in the current directory. Therefore, 'grep -i finder *' run from your home directory will search any file in the root of your home directory for the string 'finder', case-insensitively. You might want to try 'cd /; grep -r -i finder *'. The cd will take you to the top level of the filesystem, and the '-r' will tell grep to recursively search all directories, so you won't just be limited to the top level of your hard drive. Of course, to save time, perhaps cd to the directory you are trying to search.
If you are looking to search by file name, check out the find command instead.
|
|
"Think Different. Like The Rest Of Us."
iBook G4/1.2GHz | 1.25GB | 60GB | Mac OS X 10.4.2
Athlon XP 2500+/1.83GHz | 1GB PC3200 | 120GB | Windows XP
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2002
Location: Hilton Head, SC
Status:
Offline
|
|
Originally posted by macmike42:
grep doesn't search for file names, it searches the contents of files.
What do you mean the contents of files? Can you give an example? Perhaps display a command and the subsequent output? Thanks!
|
|
|
| |
|
|
|
 |
|
 |
|
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status:
Offline
|
|
Originally posted by Tyler McAdams:
What do you mean the contents of files? Can you give an example? Perhaps display a command and the subsequent output? Thanks!
man grep
|
|
"Have sharp knives. Be creative. Cook to music" ~ maxelson
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2002
Location: Hilton Head, SC
Status:
Offline
|
|
Originally posted by philzilla:
man grep
I'm currently at work on my windows box, I can't man grep...
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jun 2002
Location: UK
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Feb 2000
Status:
Offline
|
|
... actually:
grep <options> pattern file
would be more accurate.
in any event you may also be interested in the r switch, which will recursively traverse directories:
grep -ri finder *
BTW: * tells grep to match ANY file, you could also replace it with something like:
grep -ri foo*
which would only match files whose names started with the 3 letters f, o, and o or exactly matched foo.
But as the prior reply mentioned time to do a little work on your own, as the web is literally littered with good file globbing, regular expression, etc tutorials which pretty much apply to ANY version of UNIX or UNIXlike OSes. That being said regular expressions are really not all that trivial and can take years to figure the entirety of the power, however much of it is fairly esoteric and usage/experience based/theoretical knowledge based. i.e. its much easier to understand if you have some knowledge of the theory of grammars in the computer science context.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2002
Location: Hilton Head, SC
Status:
Offline
|
|
Originally posted by cutterjohn:
... actually:
grep <options> pattern file
would be more accurate.
in any event you may also be interested in the r switch, which will recursively traverse directories:
grep -ri finder *
BTW: * tells grep to match ANY file, you could also replace it with something like:
grep -ri foo*
which would only match files whose names started with the 3 letters f, o, and o or exactly matched foo.
But as the prior reply mentioned time to do a little work on your own, as the web is literally littered with good file globbing, regular expression, etc tutorials which pretty much apply to ANY version of UNIX or UNIXlike OSes. That being said regular expressions are really not all that trivial and can take years to figure the entirety of the power, however much of it is fairly esoteric and usage/experience based/theoretical knowledge based. i.e. its much easier to understand if you have some knowledge of the theory of grammars in the computer science context.
So it's: grep thetextiwant thefileiwanttosearchin
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|