Operating System - HP-UX
1833059 Members
2508 Online
110049 Solutions
New Discussion

Find command to find part of a filename

 
SOLVED
Go to solution
Simon R Wootton
Regular Advisor

Find command to find part of a filename

I need to find a file that may be buried in one of many directories each containing thousands of files.

The filename will will consist of the user id (eg. lst24) and other numbers (eg. 050217) - making the filename = lst24050217.

Question : How do I use the 'find' command to search the sub-directories to look for the file based on the user id info - I'm interested in all files created by this user.

All help rewarded ! Many Thanks.

Simon
7 REPLIES 7
Robert-Jan Goossens
Honored Contributor
Solution

Re: Find command to find part of a filename

Hi Simon,

# find /dir -user user_id -exec ll {} \;

change the user_id to a name or id number.

Robert-Jan
Gordon  Morrison
Trusted Contributor

Re: Find command to find part of a filename

Hi simon,
cd to the directory you want to start looing under and type:

find . -name lst24

Note the spaces on each side of the dot!
What does this button do?
Pete Randall
Outstanding Contributor

Re: Find command to find part of a filename

Or -

find . -name 'lst24*'


Pete

Pete
Gordon  Morrison
Trusted Contributor

Re: Find command to find part of a filename

D'OH!
I forgot the *
What does this button do?
T G Manikandan
Honored Contributor

Re: Find command to find part of a filename

#find . -user lst24 -print
V. Nyga
Honored Contributor

Re: Find command to find part of a filename

Hi,

find searches also in subdirectories, so
find /dir -name "lst24*"

Instead of /dir you can change in that directory and search with '.'
'-name' searches for the file name '-user' would do it for the user name.
'*' is the wildcard - you can set it anywhere, but you have to use the "" then.

If you wanna see more of the files, you can add the '-exec ll {} \;' like RJ said.

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
Simon R Wootton
Regular Advisor

Re: Find command to find part of a filename

Sorted - Thankyou v much!