how to search a combination of directory and file?
For example, I want to search a pattern like directory/file, how to do that?
If I simply use Code:
find . -name directory/file find: warning: Unix filenames usually don't contain slashes (though pathnames do). That means that '-name 'BASIC_REF/WAVECAR'' will probably evaluate to false all the time on this system. You might find the '-wholename' test more useful, or perhaps '-samefile'. Alternatively, if you are using GNU grep, you could use 'find ... -print0 | grep -FzZ 'foo/file''. |
The answer is in the error message you posted...
Code:
You might find the '-wholename' test more useful, or perhaps '-samefile'. For example: Code:
find ./path -iwholename '*subdir/filename' |
1. Have you considered combining find with grep to accomplish the search?
2. You have been doing this stuff for a while. Had you not encountered the "locate" command? 3. What distribution and version are you using? The default tools (and versions) differ so it is always good to mention this in your question post. |
Quote:
Code:
find . -iwholename 'filename' Code:
find ./path -iwholename '*subdir/filename' Anything further help? |
Quote:
I am a light linux user and search/ask when I ran into a specific issue. So far I only encountered find, and never used it with confidence (constantly failed to return what I want). I have not had a chance to use "locate" yet. I am looking for solutions which can be generically applied to most linux versions, thus hadn't tried to provide my linux version, which is actually linux mint mate64 installed in virtualbox. |
Quote:
Next, './path' in my example is not literal, it should be the path on your system down which you want to search. For example to search from the current directory use '.' or './', or to search your home directory use '~/'. Using your original example, the find command might be like this (tested locally): Code:
ls -l snippets/another/BASIC_REF/ Hope this helps! |
All times are GMT -5. The time now is 12:30 AM. |