nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Implementation of find command in Perl

This is a discussion on Implementation of find command in Perl within the Shell scripting forums, part of the Development/Scripting category; hi, Can u help me to implement find command of unix with -print, -exec, -name options using perl........


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 14-08-2007, 02:52 PM
Junior Member
User
 
Join Date: Aug 2007
Location: Pune
OS: Debian
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Bhushan is on a distinguished road
Question Implementation of find command in Perl

hi,
Can u help me to implement find command of unix with -print, -exec, -name options using perl.....
Reply With Quote
  #2 (permalink)  
Old 16-08-2007, 04:53 PM
Junior Member
User
 
Join Date: Jul 2007
Location: Cedar Falls, IA
OS: Fedora
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
A.L.E.X is on a distinguished road
Default

I'm not sure I understand what you are trying to do ..... if you want to execute a shell command using perl .. AFAIK, you can use the following formula :
system("COMMAND");
for example :

Code:
system("find /home -type d -iname "nixcraft" -print -exec ls {} \;");
I'm not into perl but I'm trying to help
Reply With Quote
  #3 (permalink)  
Old 22-08-2007, 12:15 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
OS: Debian GNU/Linux
Posts: 506
Thanks: 0
Thanked 8 Times in 6 Posts
Rep Power: 7
monk has a spectacular aura about monk has a spectacular aura about
Default

Go for the File::Find perl module. It include Find() function that mimics the UNIX/Linux find command and will traverse a file tree. Here's the API for the method:
Code:
Find(\&yoursubroutine, "/tmp", "/usr",..);
Official find help page find - traverse a file tree - search.cpan.org

More examples @ http://www.unix.org.ua/orelly/perl/sysadmin/ch02_04.htm

A.L.E.X, system() is fine but file::find is way to go..

PS: always use The CPAN Search Site - search.cpan.org to get all info about perl stuff
__________________
May the force with you!

Last edited by monk; 22-08-2007 at 12:17 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
unix find out ram usage command charvi Solaris/OpenSolaris 4 10-04-2008 02:22 AM
Linux Find Out RAM CAS Latency Command andrei048 Linux hardware 1 04-01-2008 10:56 AM
Use memory command to find details under Fedora Linux chiku Getting started tutorials 0 29-04-2007 08:35 PM
Find out information about my file - explaining ls command sweta Getting started tutorials 1 11-01-2007 04:21 PM
how to find perl version All about FreeBSD/OpenBSD/NetBSD 1 28-01-2006 05:20 PM


All times are GMT +5.5. The time now is 11:18 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38