- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Operating System - Tru64 Unix
- >
- Re: a Pearl script that reads through all sub dire...
Operating System - Tru64 Unix
1748198
Members
2560
Online
108759
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО04-30-2007 10:51 AM
тАО04-30-2007 10:51 AM
Hi,
I have not scripted in Pearl before. I am aware that Pearl is a great tool for dealing with files.
I need to get the list of all the files (not directories) in the current directory as well as the sub directories.
Is there a pearl script/command readily available to do this sort of thing.
what I am looking for is
execute
pearl_script
output will be a text file containing all the files in the 'Directory Name' as well as all it's sub directories.
I have NEVER touched Pearl so if you have command that does that with correct parameters. Please provide some details so that I can use it.
Any information you can provide would be helpful.
I have not scripted in Pearl before. I am aware that Pearl is a great tool for dealing with files.
I need to get the list of all the files (not directories) in the current directory as well as the sub directories.
Is there a pearl script/command readily available to do this sort of thing.
what I am looking for is
execute
pearl_script
output will be a text file containing all the files in the 'Directory Name' as well as all it's sub directories.
I have NEVER touched Pearl so if you have command that does that with correct parameters. Please provide some details so that I can use it.
Any information you can provide would be helpful.
Solved! Go to Solution.
- Tags:
- Perl
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2007 11:01 AM
тАО04-30-2007 11:01 AM
Re: a Pearl script that reads through all sub directories
Perl, not pearl.
Why perl?
find -type f
or, perhaps:
( cd ; find . -type f)
depending on exactly what you'd like to see.
> output will be a text file
Redirect stdout to a file.
find -type f > out_file
Why perl?
find
or, perhaps:
( cd
depending on exactly what you'd like to see.
> output will be a text file
Redirect stdout to a file.
find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-30-2007 11:43 AM
тАО04-30-2007 11:43 AM
Re: a Pearl script that reads through all sub directories
Hi Steven,
Thanks for the response and the correction!
The reason for Peal is because I need to use it as a script for Matlab Program. This way I am O.S independent as Matlab can run Perl Scripts internally on Linux, Unix, Windows Platform.
Nipun
Thanks for the response and the correction!
The reason for Peal is because I need to use it as a script for Matlab Program. This way I am O.S independent as Matlab can run Perl Scripts internally on Linux, Unix, Windows Platform.
Nipun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-01-2007 12:37 AM
тАО05-01-2007 12:37 AM
Solution
Hi there,
I hear you on the multiplatform thing.
I have a collection of perl scripts to help with SAP benchmarks and the exact same scripts all work on HPUX, Tru64, Linux, Windoze.
Now with perl there is always more than one way to do something.
For your question you want to read up on
- glob
- readdir
- module: File::Find;
------------------ partial find example ---
# loop through arguments which are all the tops of directory trees, looking for non-zero-length files called .err or .elg
use warnings;
use strict;
use File::Find;
my ($arg, $i);
my (%found);
while ( $arg = shift @ARGV ) {
print ++$i, " $arg\n";
chomp $arg;
foreach (glob ($arg)) {
print ++$i, " - \'$_\'\n";
find(\&wanted, $_) if -d;
}
}
sub wanted {
my ($type, $size, $file, $spec);
if (/\.(err|elg)/i && -f $_ && ($size=-s)) {
$type = $1;
$spec = $File::Find::name;
$file = $_;
:
-------------------- READDIR --------
:
opendir(DIR,$source) || &error(__LINE__,"opendir");
@entries = grep(!/^\.\.?$/,readdir(DIR));
closedir(DIR) || &error(__LINE__,"closedir");
:
------------------ simple glob --------
while ($files = shift @ARGV) {
while ($file = glob ($files)) {
:
---------------- simpler glob -----
perl -le 'print while (<*.csv>)'
Hein.
I hear you on the multiplatform thing.
I have a collection of perl scripts to help with SAP benchmarks and the exact same scripts all work on HPUX, Tru64, Linux, Windoze.
Now with perl there is always more than one way to do something.
For your question you want to read up on
- glob
- readdir
- module: File::Find;
------------------ partial find example ---
# loop through arguments which are all the tops of directory trees, looking for non-zero-length files called .err or .elg
use warnings;
use strict;
use File::Find;
my ($arg, $i);
my (%found);
while ( $arg = shift @ARGV ) {
print ++$i, " $arg\n";
chomp $arg;
foreach (glob ($arg)) {
print ++$i, " - \'$_\'\n";
find(\&wanted, $_) if -d;
}
}
sub wanted {
my ($type, $size, $file, $spec);
if (/\.(err|elg)/i && -f $_ && ($size=-s)) {
$type = $1;
$spec = $File::Find::name;
$file = $_;
:
-------------------- READDIR --------
:
opendir(DIR,$source) || &error(__LINE__,"opendir");
@entries = grep(!/^\.\.?$/,readdir(DIR));
closedir(DIR) || &error(__LINE__,"closedir");
:
------------------ simple glob --------
while ($files = shift @ARGV) {
while ($file = glob ($files)) {
:
---------------- simpler glob -----
perl -le 'print while (<*.csv>)'
Hein.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP