- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script help
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
Discussions
Discussions
Forums
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
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-03-2005 12:13 PM
тАО03-03-2005 12:13 PM
script help
#!/usr/bin/csh
set list = `ls`
foreach file ( $list )
set size = `wc -c $file`
if( (-f $file) && ($size[1] < 1000) ) echo $file
end
---------------------------------------------------
What will the following Perl script print out?
----------------------------------------------
#!/usr/bin/perl -w
use strict;
my @files = ('something.data',
'file.dat',
'data.txt',
'alpha.datdat',
'beta.a.dat');
my @list = ();
foreach my $file (@files) {
next if ( $file !~ m/\.dat$/i );
push(@list, $file);
}
foreach my $item (@list) { print "$item\n"; }
exit;
Please..could anyone help?
Thanks
Joe
- Tags:
- csh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2005 08:37 PM
тАО03-03-2005 08:37 PM
Re: script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2005 09:19 PM
тАО03-03-2005 09:19 PM
Re: script help
perl script:
create an array (@files) and populate with data
create an empty array(@list)
go through the entries in the files array
if the entry ends in a ".dat" append to list array
print each of the entries in the list array
Regards
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-03-2005 10:23 PM
тАО03-03-2005 10:23 PM
Re: script help
--8<---
#!/usr/bin/perl -lw
use strict;
my @files = qw(something.data
file.dat data.txt alpha.datdat beta.a.dat);
my @list = grep /\.dat$/i => @files;
print for @list;
-->---
the list @files is a list of predefined file names. @list is then stuffed with the names that match the file names that end on .dat (case insensitive), and that list is then printed to the standard output (your screen)
and reduce that to
--8<---
#!/usr/bin/perl -lw
use strict;
print for grep /\.dat$/i => qw(something.data
file.dat data.txt alpha.datdat beta.a.dat);
-->---
Which was probably an elaborate way to check what would happen on
# perl -lwe'print for grep m/\.dat$/i => <*dat*>'
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2005 12:02 AM
тАО03-07-2005 12:02 AM
Re: script help
is this still a problem?
If not can you please identify the solution and close the thread, otherwise please update.
Thanks