- 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
Forums
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
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-13-2004 01:18 PM
11-13-2004 01:18 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2004 05:16 PM
11-13-2004 05:16 PM
Solutionput the file inot Linux(we are in linuxland).
while read -r filename
do
rm -f $filename
done < filelist
That will nuke them all and fast.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2004 05:29 PM
11-13-2004 05:29 PM
Re: perl help/excel/delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2004 07:24 PM
11-13-2004 07:24 PM
Re: perl help/excel/delete
Sep said to cut and paste the filenames fro your excel sheet and create a file with it then create the script he posted and let it run in the same dir as your filelist. If you do only have relative filenames than you will have to put both files at the top of your filenames path.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2004 10:07 AM
11-14-2004 10:07 AM
Re: perl help/excel/delete
"while: Expression Syntax".
The code I am using is:
#!/bin/csh
while read -r newset
do
rm -f $newset
done < filelist
What am I doing wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2004 10:47 AM
11-14-2004 10:47 AM
Re: perl help/excel/delete
Change the #!/bin/csh to just #!/bin/sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2004 11:45 AM
11-14-2004 11:45 AM
Re: perl help/excel/delete
I have another question. From my new list of files I want to select 1000 random files.
How would I select the 1000 random files and delete them from the current folder and put them in another folder?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2004 12:15 AM
11-15-2004 12:15 AM
Re: perl help/excel/delete
what do mean by random?
You can select with CTRL+mouseclick and number of files in your excel sheet, create the filelist and use mv instead of rm in the script.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2004 01:13 AM
11-15-2004 01:13 AM
Re: perl help/excel/delete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2004 01:26 AM
11-15-2004 01:26 AM
Re: perl help/excel/delete
from what source and according to what criteria is the computer to select the files?
greetings,
Michael
- 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.