- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help with find syntax
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
Forums
Discussions
Discussions
Discussions
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
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
03-04-2004 04:45 AM
03-04-2004 04:45 AM
While I was out on vacation several problems developed with our N4000 running 11i. I think my temporary replacement is to blame. A number of applications are failing with "file not found" and I think I have found the problem. A number of symbolic links refer to files that are missing. I've been trying to write a script using find. Basically, I'm doing this:
find /user /work -type l -exec ls -l {} \; > /tmp/filelist
That is finding the symbolic links but I am having trouble dealing with the absolute pathnames and relative pathnames. Is there another find option that will help?
Thanks,
Steve
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 04:52 AM
03-04-2004 04:52 AM
Re: Help with find syntax
Would the following work for you?
find /tmp -type l |xargs ll -d
This way ls -l doesn't traverse the sub directories and it will work for files too.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 04:53 AM
03-04-2004 04:53 AM
SolutionWell, I will give you a find hint. Use Perl's File::Find. It keeps up with the current directory and you can do your own thing inside the 'wanted' subroutine.
The problem with trying to parse ls -l
is the "xxx -> yyy" at the end of each ls -l output line. Separating the -> part from everything else is pretty simple BUT if the filenames have whitespaces (and they could) then things get very tricky. That still does not address the relative/absolute path problems.
I recently wriote a Perl script that was very close to your needs. Give me a few minutes and I'll modify it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 05:01 AM
03-04-2004 05:01 AM
Re: Help with find syntax
I completely misunderstood (rather misread) your question.
May be one solution is to make use of 'basename' and|or 'dirname' commands to get what you want. For ex., if the link is like
/dir1/dir2/file -> file2
you can get the dir name of the first file with 'dirname /dir1/dir2/file'. basename will skip the directory tree and give you only the file name. A combination of both may work for you.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 05:14 AM
03-04-2004 05:14 AM
Re: Help with find syntax
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=470847
Although I didn't have to use it, Perl has the readlink() function just like the readlink() system call and the lstat() function as well. It took me longer to modify the Usage() message than it did to modify the "meat" of the code.
Use it like this:
badslink.pl /home /usr
or
badslink.pl
The latter case will descend starting at the CWD. Invoke as badslink.pl -u for full usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 09:11 AM
03-04-2004 09:11 AM
Re: Help with find syntax
My question now is what happens when I mount a filesystem under a directory that already has files in it?
BTW, he is a Windows guy.
Thanks,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2004 09:18 AM
03-04-2004 09:18 AM