nixCraft Linux Forum

nixCraft

Linux 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

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 08-14-2007, 03:52 PM
Junior Member
User
 
Join Date: Aug 2007
Location: Pune
My distro: Debian
Posts: 1
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
Sponsored Links
  #2 (permalink)  
Old 08-16-2007, 05:53 PM
Junior Member
User
 
Join Date: Jul 2007
Location: Cedar Falls, IA
My distro: Fedora
Posts: 3
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 08-22-2007, 01:15 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
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; 08-22-2007 at 01:17 PM..
Reply With Quote
Reply

Bookmarks


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 On

Similar Threads

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


All times are GMT +5.5. The time now is 07:51 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

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