- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Can I use two "-exec" in a "find" command?
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
06-09-2008 08:42 AM
06-09-2008 08:42 AM
I want to find a filename, and ls -al on it, and also cat it. I want to use the following, but it could not work. What is wrong, any "connection" symbol I should use between these two -exec?
find / -name 'filename' -exec /bin/ls -al {} -exec /usr/bin/cat {} \;
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 08:47 AM
06-09-2008 08:47 AM
Re: Can I use two "-exec" in a "find" command?
You need to substitute a simple script to run the multiple commands you want:
# find / -name filename -exec /tmp/myscript {} \;
# cat /tmp/myscript
#!/usr/bin/sh
ls -l "$@"
cat "$@"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 09:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 09:23 AM
06-09-2008 09:23 AM
Re: Can I use two "-exec" in a "find" command?
TTr, That is exactly what I am looking for.
But, I am also interested in JFR's, but can I do that in the same file? It could not work though....
find / '.rhosts' -exec list {} \;
list ()
{
ls -l "$@"
cat "$@"
}
6 find / '.rhosts' -exec list {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 09:43 AM
06-09-2008 09:43 AM
Re: Can I use two "-exec" in a "find" command?
If you would prefer not to have a small script that receives the 'find' output for post-processing, I think TTr has provided a straight-forward, simple solution!
I don't see a simple way to create one script as you secondarily asked.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 09:57 AM
06-09-2008 09:57 AM
Re: Can I use two "-exec" in a "find" command?
On second thought, this works:
# cat ./myscript
#!/usr/bin/sh
function list {
for FILE in $@
do
ls -l "${FILE}"
cat "${FILE}"
done
}
list $( find /path -type f -print )
exit
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 11:13 AM
06-09-2008 11:13 AM
Re: Can I use two "-exec" in a "find" command?
#!/usr/bin/sh
find / -name \.rhosts |
while read filename
do
ls -l $filename
cat $filename
done
If you leave out the first line (#!/usr/bin/sh) you can type the above script exactly as you see it on the command line and it will work too.