find file with dir/file pattern
hello,
i'm just curious if i can search for the dir/file pattern in the single "find" command? here is an example: dir1/dir2/dir3/file.txt dirXX/dirYY/dir2/dir3/file.txt dir1/dir4/dir3/file.txt i want to search for the pattern "dir2/dir3/file.txt" |
man find
/regex Cheers, Tink |
Have you looked at the 'find' command. It has a lot of options, such as setting type to regular file, specifying the desired path, and even things like newer / older than a particular time. A simple example, assuming I am interpreting your examples correctly, would be like:
Code:
find ./dir1/dir2 -type f -name file.txt -print |
The search directory or directories are given separately from the filename, so if you want to find a particular file, file.txt, in directory /home/me/myfiles you would search by:
find /home/me/myfiles -name file.txt You can also search more than one directory for filenames or patterns, for example: find /etc /var -name '*.log' The find utility is a very powerful search tool. Refer to the man pages for more information. |
i think i didn't formulate my question right. Let me clarify :
i want to search for the pattern "dir2/dir3/file.txt", not from the current directory, but across several other directories. The idea is that the same file (file.txt) maybe in several directories and to uniquely identify the right one i need to bring the 2 directories (above it) into equation... hope this helps . If not - please let me know. So in Noway2's example, i can't use dir1/dir2 as a starting search directory - because i should be able to search in any directory. smth like this : find directory_Blah -name 'dir2/dir3/file.txt' I probably should also note that i'm stuck on Solaris. ( don't have gnu here ) To Tink: man find /regex Pattern not found :). I did RTFM and nothing caught my eye. I tried playing with ' and \ as well as adding * instead of /. But that didn't help. apparently i'm missing smth obvious. |
Quote:
|
Quote:
|
This should tell you:
Code:
$ find --version |
Quote:
find: [-H | -L] path-list predicate-list |
Quote:
I do not know if your 'find' has those options but you might want to search for '-path' and/or '-wholename' option in the manpage. |
Quote:
Yeah, the find that comes with Solaris by default is an antique, doesn't know half the features of GNU find. Easiest will be to find . -type f | grep dir1/dir2/file. Cheers, Tink |
Quote:
Here is the link to find's man page, that looks like the one i;m dealing with http://www.bga.org/~lessem/psyc5112/...is/find.1.html |
Quote:
|
All times are GMT -5. The time now is 03:49 AM. |