Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

-aggie-

macrumors P6
Original poster
Jun 19, 2009
16,793
51
Where bunnies are welcome.
I know about locate and find, but when I use them on SSH, either I get an error or it just returns with nothing (even though I know the files are on my iPhone).

I’ve used:

find . -name filename.txt

and nothing comes up.

Using:

locate filename.txt

I get an error and nothing comes up.
 
If you want to search the entire phone with that find command, you have to be at the device root

cd /
 
Doesn't the "." after the find command mean "current directory"? What happens if you try it without the dot or use an "*" instead?
 
I know about locate and find, but when I use them on SSH, either I get an error or it just returns with nothing (even though I know the files are on my iPhone).

I’ve used:

find . -name filename.txt

and nothing comes up.

Using:

locate filename.txt

I get an error and nothing comes up.

aggie,

The "locate" command is not what you want.

Try this:

find / -name "Helvetica*"

This recursively looks for and lists any file that starts with "Helvetica*" starting at the root directory.

This command does the same from the current working directory:

find . -name "Helvetica*"

S-
 
Doesn't the "." after the find command mean "current directory"? What happens if you try it without the dot or use an "*" instead?

Still doesn’t work. It just comes back with a new line; almost like it didn’t find the file. I even went to the directory where the file I am looking for is and tried the command and get nothing.


Edit: Figured it out. I just needed the -print at the end. Now it searches in all directories at or below where I’m searching:

find . -name "filename.*" -print

Edit: @sidewinder: Didn’t notice you had replied. Yes, that works also. Thanks. I’m thinking it was that I didn’t have the filename in quotes and had nothing to do with the -print.
 
aggie,

If you don't care or want to be case sensitive in the search use this command"

find / -iname "helvetica*"

Note: On my iPhone, I have not needed the "-print" option. But I am not sure if the standard "find" command needs it nor what "find" command I have on my iPhone. So you might need this command:

find / -iname "helvetica*" -print

Heck, if you want to count the number of matches, you could do this:

find / -iname "helvetica*" -print | wc -l

S-
 
Edit: @sidewinder: Didn’t notice you had replied. Yes, that works also. Thanks. I’m thinking it was that I didn’t have the filename in quotes and had nothing to do with the -print.

I don't need the quotes. This command works just fine on my iPhone:

find / -iname helvetica.ttf

S-
 
I think I got that version of find from the "Find Utilities" (4.2.33-6). I didn't install these directly myself so I assume some app I installed had them as a dependency.

S-
 
I think the locate database doesn't update automatically, make sure to run "updatedb" command before a search ("locate -u" will do the same)
 
I use the locate command.

- First update the database by "updatedb"
- Wait until its done (20 seconds or so)
- locate filename

ie: locate root# locate cydia
/private/etc/apt/sources.list.d/cydia.list
etc ....

Works like a charm for me.
 
There are a few issues with the "locate" command.

The first is that the database takes up a decent amount of space. On my phone it uses almost 1MB. That doesn't sound like much but it all adds up.

Second, you manually have to update the database.

Third, the path cannot be constrained. In other words, it searches the entire db.

The "find" command doesn't have these issues. Yes, it is slower than "locate", but not by much.

S-
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.