- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Find file based on list
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2009 02:09 PM
тАО11-11-2009 02:09 PM
Example name.txt contains
573_-_mm-cubeside180
573_-_mm-cubeside270
573_-_mm-cubeside90
573_-_mm-datum-ring
573_-_mm-datumringstand
I want to use 'find' to located them on disk with adding file extention.
example: find /tool -name 573_-_mm-cubeside180*.prt
And use the output from 'find' to exec ls -l on the full path of the file.
Solved! Go to Solution.
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2009 02:19 PM
тАО11-11-2009 02:19 PM
Re: Find file based on list
Give your file named 'name.txt' with each line representing a filename, you could do:
while read NAME
do
find /tool -xdev -type f -name "${NAME}*.prt" -exec ls -l {} +
done < name.txt
I use the -xdev' so as not to cross mountpoints. I use the '-type f' to restrict us to files and not directories, etc. The use of the "+' terminator means that multiple arguments (here, filenames) can be collected and passed to one instantation of the command ('ls'). This is quite efficient.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2009 02:19 PM
тАО11-11-2009 02:19 PM
Re: Find file based on list
You can used find command with for loop
i.e.
for i in `cat name.txt`
do
find . -name $i -exec ls -l {} \; >/tmp/find.out
done
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2009 05:27 AM
тАО11-12-2009 05:27 AM
SolutionPossibly something like:
find /tool $(
awk '
BEGIN { print "(" }
{
print "-name " $1 "*.prt -o "
}
END { print " -name bad_Xname )" } ' < name.txt
) -exec ll +
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2009 05:59 AM
тАО11-12-2009 05:59 AM
Re: Find file based on list
@ Dennis: That's a very nice solution to keep from abusing the server! :-)
@ Mike: No points for this comment, please.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2009 06:04 AM
тАО11-12-2009 06:04 AM
Re: Find file based on list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2009 04:24 PM
тАО11-13-2009 04:24 PM
Re: Find file based on list
find /tool -name "*.prt" | fgrep -f name.txt | xargs ll