- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- perl help/excel/delete
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
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
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
11-15-2004 01:48 AM
11-15-2004 01:48 AM
Re: perl help/excel/delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2004 04:13 AM
11-15-2004 04:13 AM
Re: perl help/excel/delete
you look for something like:
#!/bin/ksh
cd /tmp
for FILE in `ls | head -1000`
do
mv ${FILE} /pathto
done
?
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2004 03:26 PM
11-17-2004 03:26 PM
Re: perl help/excel/delete
The program is not selecting 1000 random files. It is selecting the files in order. I am not sure why that is happening. I have over 3000 files and I need to select 1000 random files out of the 3000. Any ideas?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2004 03:57 PM
11-17-2004 03:57 PM
Re: perl help/excel/delete
$ random.pl
should return
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2004 04:34 PM
11-17-2004 04:34 PM
Re: perl help/excel/delete
Did I enter the information correctly?
Can the files be moved from one folder to another?
Thanks
#!/usr/bin/perl
if (scalar(@ARGV) != 2) {
die "usage: $0 ~/documents/erule/test/test2 20\n";
}
@files = <$ARGV[0]/*>;
fisher_yates_shuffle(\@files);
$, = "\n";
print splice(@files, 0, $ARGV[1]);
print "\n";
sub fisher_yates_shuffle {
my $deck = shift; # $deck is a reference to an array
my $i = @$deck;
while ($i--) {
my $j = int rand ($i+1);
@$deck[$i,$j] = @$deck[$j,$i];
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2004 04:46 PM
11-17-2004 04:46 PM
Re: perl help/excel/delete
$ ./random.pl ~/documents/erule/test/test2 20 | while read file
do
echo mv $i
done
If printout is ok remove 'echo' from the last second line (before mv).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2004 06:54 PM
11-17-2004 06:54 PM
Re: perl help/excel/delete
$ ./random.pl ~/documents/erule/test/test2 20 | while read file
do
echo mv $file
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2004 03:12 AM
11-18-2004 03:12 AM
Re: perl help/excel/delete
#!/usr/bin/perl
if (scalar(@ARGV) != 2) {
die "usage: $0 ~/documents/erule/test 20\n";
}
@files = <$ARGV[0]/*>;
fisher_yates_shuffle(\@files);
$, = "\n";
print splice(@files, 0, $ARGV[1]);
print "\n";
sub fisher_yates_shuffle {
my $deck = shift; # $deck is a reference to an array
my $i = @$deck;
while ($i--) {
my $j = int rand ($i+1);
@$deck[$i,$j] = @$deck[$j,$i];
}
}
My second problem is with the second script you told me to use. It is giving me errors. I am sure I am doing something wrong. Here is the script I used for that.
#!/usr/bin/perl
$ ./randomfl.pl ~/documents/erule/test 20 | while read file
do
echo mv $file ~/documents/erule/test/test2
done
What mistake am I making?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2004 05:17 AM
11-18-2004 05:17 AM
Re: perl help/excel/delete
the second script is actually a shell script and the $ was the prompt from the shell. Replace /usr/bin/perl with /usr/bin/sh
That should make it work.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2004 10:04 AM
11-18-2004 10:04 AM
Re: perl help/excel/delete
./randomfl.pl ~/documents/erule/test 20
That should return list of 20 randomly selected files.
I assume that you are running this on Linux.
- « Previous
-
- 1
- 2
- Next »