View previous topic :: View next topic |
Author |
Message |
_______0 Guru
Joined: 15 Oct 2012 Posts: 521
|
Posted: Sat Nov 02, 2013 7:05 pm Post subject: find option like grep? |
|
|
hi,
The command find is useful but its options' semantics make it slow.
dis crazy:
'libavcodec*' or '*foo*'
Does find have an option for fuzzy search like grep? And banish quotes entirely.
The ideal option, for certain stuff is this:
find ./ -iname 'portion of file name' (without the quotes)
the following example:
Code: | find ./ -iname codec |
would return this
Code: | libavcodec.so.53
libavcodec.so.54
libavcodec.so |
thanks. |
|
Back to top |
|
|
Atom2 Apprentice
Joined: 01 Aug 2011 Posts: 185
|
Posted: Sat Nov 02, 2013 8:23 pm Post subject: |
|
|
I am not aware that find (alone) can do what you are after. Having said that, I think there are two options to achieve what you want:
In case you wanna get rid of the the quoting mechanism and use parts of a file name as the matching criteria, you could use output redirection into a file and then grep that file or, in case you want everything in one command, pipe find's output directly to grep (which I'd prefer). That should not be too slow if you instruct find to only print out the names of files (it would just traverse every directory and print the file names which is actually pretty fast) and let grep do the search for the 'portion of file name' as you have put it. If there's no terminal output involved, this is very fast indeed.
If, on the other hand, you are after more flexibility in the search pattern (like grep's regular expressions) then you could combineto set the types of regular expressions that find understands and combine this option withfor case sensitive searches orfor case insensitive searches.
It's probably worth noting that quoting the search strings is required with grep and find (and also any other command) to protect wildcard characters from being interpreted by the shell before being passed to the command as an argument. So the quoting is not really special to find at all.
I hope that helps. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|