![]() |
|
|
#23 |
|
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
24·593 Posts |
Ah. The script needed Windows-proofing and usability testing.
It's the Windows-style line breaks that were confusing it. Looks good! Thanks. |
|
|
|
|
|
#24 |
|
"Mark"
Apr 2003
Between here and the
24×397 Posts |
How does one use this script to remove candidates from an ABC file?
|
|
|
|
|
|
#25 |
|
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
24×593 Posts |
Can't say anything about ABCD files, but for ABC I simply do
(e.g. if the hint script said "remove n= 1 mod 3") this: head -1 myold.npg > mybetter.npg tail +2 myold.npg | awk '$2%3!=1' >> mybetter.npg I do that as early as possible, after the script is done, the "hiddenPowers pl_remain.txt" is run and initial srsieve runs are done. Some "mybetter.npg" (for individual k's) files will become empty after the above filtering. ...and then merge all npg files with sort +1n and awk into the ABC file... Later .npg files can be sieved some more as needed, and re-merged, etc. Last fiddled with by Batalov on 2010-03-19 at 22:21 |
|
|
|
|
|
#26 | |
|
Account Deleted
"Tim Sorbera"
Aug 2006
San Antonio, TX USA
17·251 Posts |
Quote:
).Here it is: http://www.mersenneforum.org/showthr...328#post199328 An example usage would be: (doing this manually, where lines starting with ">" show a command that was run) Code:
>hiddenPowers.pl pl_remain.txt 64*177^n-1 n=0 mod 2 factors due to 8^2 64*177^n-1 n=0 mod 3 factors due to 4^3 >mod.pl 177-file 64 0 2 >mod.pl 177-file-out 64 0 3 >ren 177-file-out-out.txt the-result.txt It might be worthwhile to merge hiddenPowers.pl and mod.pl, or make a modification of hiddenPowers.pl that optionally runs mod.pl. If I have some free time over the weekend (I should), and feel like it, (I probably will) I'll at least look in to this. Last fiddled with by Mini-Geek on 2010-03-19 at 23:43 |
|
|
|
|
|
|
#27 |
|
Account Deleted
"Tim Sorbera"
Aug 2006
San Antonio, TX USA
102538 Posts |
remove-ks.pl 3.2.1:
Code:
#!/usr/bin/perl
# remove-ks.pl 3.2.1
# usage:
# have a file with one k or prime per line (k's to remove)
# have at least one of:
# a file of remaining k's present (e.g. pl_remain.txt)
# a sieve file present, in a format that has the k on every line, e.g. PFGW/NewPGen's "k n", and not ABCD
#
# have egrep present
# run 'perl remove-ks.pl -p primefile -s sievefile -r remainingksfile' (-p mandatory, need at least one of -s and -r)
# e.g. 'perl remove-ks.pl -p pfgw.log -s work.txt -r pl_remain.txt' deletes all k's with primes (found in pfgw.log) from work.txt and pl_remain.txt
# or 'perl remove-ks.pl -p pfgw-prime.log -r pl_remain.txt' deletes all k's with primes (found in pfgw-prime.log) from pl_remain.txt
# the prime file can have, per line: a single k, (e.g. "1234") a prime, (e.g. "1234*3^2345-1") or a sequence (e.g. "1234*3^n-1");
# really anything, as long as it starts with the k, and if it continues, the k is followed by a *
# (e.g. "1234", "1234*3^2345-1", "1234*3^n-1", and "1234*JUNKTEXT" are all valid and will remove k=1234)
# changelog:
# 3.2.1: improved help text, made it show all info whenever something's wrong
# 3.2: now supports command line arguments for what files to work on; also helpfully errors out if you don't give it sufficient input
# 3.1.1: removed the "?" after the "[^0-9]" since it made it match some k's that shouldn't (e.g. the code for 123 would match 1234)
# 3.1: made the search pattern start on a new line and be followed by something besides a numeral to stop many possible false positives
# 3.0: added version number; rewrote to get all the k's first, then use egrep to remove them all from both files in one shot; results in a huge speed improvement
# 2.0: (unnumbered originally) uses grep to remove k's from pl_remain.txt along with using srfile to remove them from the sieve file
# 1.0: (unnumbered originally) first release, used srfile to delete k's from a sieve file
use Getopt::Std;
getopt('spr');
$help = "must supply a file with primes (k's to remove), -p filename.txt, and\nat least one file to remove from, -r pl_remain.txt or -s sievefile.txt\n\nUsage: remove-ks.pl -p PRIME_FILE [-r K_FILE] [-s SIEVE_FILE]\n remove-ks.pl -p pfgw.log -r pl_remain.txt -s sieve.txt";
if (length($opt_p) < 1) { # if no prime file was specified
print $help;
exit;
}
if (length($opt_s) < 1) {
$remsieve = 0;
} else {
$sievefile = $opt_s;
$remsieve = 1;
}
if (length($opt_r) < 1) {
$remremain = 0;
} else {
$remainfile = $opt_r;
$remremain = 1;
}
if ((!$remremain) && (!$remsieve)) { # if neither sieve nor remain file was specified
print $help;
exit;
}
$kstxt = "temp-ks.txt";
if ($remainfile == $kstxt) { # just in case the list of remaining k's is at temp-ks.txt, change our temp list
$kstxt = "temp-ks-alt.txt";
}
open(IN, $opt_p);
print "getting list of k's to remove from $opt_p...\n";
while(<IN>)
{
# get ks
$line = $_;
chomp($line);
@linearray = split(/\*/,$line);
$ks .= '^' . @linearray[0] . '[^0-9]|';
}
# remove the final | character since we don't need or want it
chop($ks);
# write the list of k's, formatted as a regex search pattern, to a file
open(OUT, ">$kstxt");
print OUT $ks;
close(OUT);
if ($remremain) {
print "done, removing k's from $remainfile...\n";
# remove k's from remaining k's file
system("egrep -vhf $kstxt $remainfile > temp.txt");
system("del $remainfile");
system("ren temp.txt $remainfile");
}
if ($remsieve) {
print "done, removing k's from $sievefile...\n";
# remove k's from sieve file
system("egrep -vhf $kstxt $sievefile > temp.txt");
system("del $sievefile");
system("ren temp.txt $sievefile");
}
# clean-up
system("del $kstxt");
print "done, exiting\n";
close(IN);
|
|
|
|
|
|
#28 |
|
Just call me Henry
"David"
Sep 2007
Cambridge (GMT/BST)
588110 Posts |
would it be possible for your script to accept as input the output from batalov's script?
|
|
|
|
|
|
#29 | ||
|
Account Deleted
"Tim Sorbera"
Aug 2006
San Antonio, TX USA
17×251 Posts |
Quote:
Quote:
Don't give hiddenPowers.pl a sieve file without having mod.pl available. (it can still run alone as long as you only give it a pl_remain.txt file) So all you have to do is run something like: hiddenPowers.pl pl_remain.txt sievefile.txt Last fiddled with by Mini-Geek on 2010-03-20 at 18:47 |
||
|
|
|
|
|
#30 | |
|
Just call me Henry
"David"
Sep 2007
Cambridge (GMT/BST)
5,881 Posts |
Quote:
Sorry to be unclear.
|
|
|
|
|
|
|
#31 |
|
Account Deleted
"Tim Sorbera"
Aug 2006
San Antonio, TX USA
17×251 Posts |
I was wondering if anybody had written a script that will copy certain results (e.g. all base 168) from a PRPnet server's completed_tests.log file, then I realized grep could trivially do this. But I like being able to just plug in a number, so I made this little extract-base.pl script:
Code:
$base = $ARGV[0]; system 'grep "\*'.$base.'\^"'." completed_tests.log > completed_tests_$base.log"; Note that this looks for "*base^", so anything whose results don't appear in that form won't be picked up. If grep is unavailable, this could be modified to use Perl's grep function. Last fiddled with by Mini-Geek on 2010-03-21 at 12:57 |
|
|
|
|
|
#32 | |
|
A Sunny Moo
Aug 2007
USA (GMT-5)
3·2,083 Posts |
Quote:
Code:
#!/usr/bin/perl
print "Enter name of input file: ";
$inputFile = <STDIN>;
chomp($inputFile);
print "Enter name of output file: ";
$outputFile = <STDIN>;
chomp($outputFile);
open(INFILE, $inputFile);
open(OUTFILE, '>', $outputFile);
$usernameLine = <INFILE>;
$datetimeLine = <INFILE>;
while(<INFILE>) {
$justRead = $_;
($knpair, $foo) = split(/ is /, $justRead);
($k, $base_n_minus1) = split(/\*/, $knpair);
($base, $n_minus1) = split(/\^/, $base_n_minus1);
($n, $one) = split(/\-/, $n_minus1);
if($n > 500000 and $n < 600001) {
print OUTFILE $usernameLine; print OUTFILE $datetimeLine; print OUTFILE $justRead;
}
$usernameLine = <INFILE>;
$datetimeLine = <INFILE>;
}
close(INFILE);
close(OUTFILE);
While this deals strictly in LLRnet-formatted results (I always convert PRPnet results to LLRnet format before processing so I can use the same scripts), it could be modified to manual LLR format by removing all such occurrences of these lines: $usernameLine = <INFILE>; $datetimeLine = <INFILE>; And changing this line: print OUTFILE $usernameLine; print OUTFILE $datetimeLine; print OUTFILE $justRead; to this: print OUTFILE $justRead; I imagine it could be converted to PRPnet format without too much hassle. |
|
|
|
|
|
|
#33 | ||
|
Account Deleted
"Tim Sorbera"
Aug 2006
San Antonio, TX USA
17·251 Posts |
Quote:
I don't think I'll be using this since right now I only need a simple task for PRPnet results and not a complex task for LLRnet-format results, but that's what this thread is for.Quote:
Code:
print OUTFILE $usernameLine.$datetimeLine.$justRead; |
||
|
|
|
![]() |
| Thread Tools | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Scripts thread | bsquared | YAFU | 4 | 2012-10-21 19:45 |
| Escape sequences in bash scripts? | CRGreathouse | Software | 16 | 2009-03-26 08:42 |
| Perl scripts for result file conversion | nuggetprime | No Prime Left Behind | 5 | 2009-01-02 19:44 |
| Tracking GIMPS progress with scripts | jasong | jasong | 21 | 2008-03-25 00:47 |
| DPGraph 2D/3D scripts | nibble4bits | Lounge | 0 | 2008-01-16 17:05 |