mersenneforum.org > YAFU APRCL and flags
 Register FAQ Search Today's Posts Mark Forums Read

 2019-04-20, 17:37 #1 mnh001   Apr 2011 10000002 Posts APRCL and flags Is there a way to have APRCL output to file without all the verbosity? I'm using yafu-Win32.exe "aprcl(@)" -batchfile in.bat > outfile.txt on the command line and it works fine. But when you have an outfile with thousands of results in it it is impractical to go through it manually trying to pull out the primes. I know I can use factor with the batchfile and use the -op flag to get no verbosity at all but it takes factor a lot longer. Eg, I have a 1.19Mb in.bat file. Using APRCL took 15 minutes to test all the numbers. Using factor took 47 minutes. And these were small numbers (19 digits long each). They only get bigger from here. If worse comes to worse I can use Excel or Word and write some VB code to go through the outfile and pull out the primes but I'm trying to avoid that. So how do I get APRCL to output ONLY the prime numbers themselves? TIA
2019-04-20, 18:16   #2
xilman
Bamboozled!

"𒉺𒌌𒇷𒆷𒀭"
May 2003
Down not across

17·619 Posts

Quote:
 Originally Posted by mnh001 I'm using yafu-Win32.exe "aprcl(@)" -batchfile in.bat > outfile.txt on the command line and it works fine. But when you have an outfile with thousands of results in it it is impractical to go through it manually trying to pull out the primes.
grep

Last fiddled with by xilman on 2019-04-20 at 18:17

 2019-04-20, 18:40 #3 mnh001   Apr 2011 26 Posts Umm, what does grep mean?
 2019-04-20, 19:42 #4 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 111101111112 Posts Regular-Expressions https://en.m.wikipedia.org/wiki/Regular_expression https://en.m.wikipedia.org/wiki/Grep You can also use JavaScript which has powerful pattern-matching capabilities and use your browser as the engine. Personally, I use a combination of notepad and Microsoft word for tasks like this. It's not worth the time to write the code to perform the pattern matching if you know how to manipulate the find and replace features of Microsoft word which can also do pattern-matching. Last fiddled with by a1call on 2019-04-20 at 19:48
 2019-04-20, 20:41 #5 EdH     "Ed Hall" Dec 2009 Adirondack Mtns 2×32×197 Posts I don't know how to use grep with Windows, but an example using linux: in.bat: Code: 791983480490047827611713671673243269719475033357020491318658587370734859917501757247280274120687620244932823203078126584367941327107909441393420761629669182060309428959781205938878991287988842504651654418555273833187612069989016960300232281081564383945219330853192499288775093985688277416598739633747 Command line: Code: $./yafu "aprcl(@)" -batchfile ./in.bat | grep "Input is prime" Result: Code: Input is prime. P300 Simply add a pipe to your out file: Code: $ ./yafu "aprcl(@)" -batchfile ./in.bat | grep "Input is prime" | >outfile.txt to send the results there.
2019-04-20, 21:34   #6
chalsall
If I May

"Chris Halsall"
Sep 2002

2×5×941 Posts

Quote:
 Originally Posted by a1call Regular-Expressions https://en.m.wikipedia.org/wiki/Regular_expression
Yeah. Every time I teach or lead teams, I make sure they get comfortable with RegEx.

My students and employees tend to hate me. I'm OK with that.

 2019-04-21, 00:43 #7 mnh001   Apr 2011 26 Posts Ah, I see. Thanks for the info. I'll see how it works.
 2019-04-21, 11:38 #8 mnh001   Apr 2011 26 Posts Well, I tried it but it tells me 'The syntax of the command is incorrect.' I'm using yafu-1.34 in Windows XP. I tried taking the pipes out and thought it worked but looking in outfile all it said was 'no switch detected'.
2019-04-21, 15:06   #9
bsquared

"Ben"
Feb 2007

2·412 Posts

Quote:
 Originally Posted by mnh001 Well, I tried it but it tells me 'The syntax of the command is incorrect.' I'm using yafu-1.34 in Windows XP. I tried taking the pipes out and thought it worked but looking in outfile all it said was 'no switch detected'.
grep is a linux command; on windows you want findstr.

I think something like this would be equivalent to EdH's command:

.\yafu-Win32.exe "aprcl(@)" -batchfile in.bat | findstr /c:"Input is prime" > outfile.txt

Last fiddled with by bsquared on 2019-04-21 at 15:06

 2019-04-21, 15:43 #10 chris2be8     Sep 2009 1,987 Posts Or just use grep etc to search the output file: Code: grep prime outfile.txt Should list just the lines in outfile.txt containing the string prime. findstr should be able to do it as well but I'm not sure of the syntax because I don't have any Windows systems. Having run yafu you can quickly try grep with various parms until you have the output you want. Chris
 2019-04-21, 15:45 #11 mnh001   Apr 2011 26 Posts Yes, this does indeed work. Thanks. It prints 'Input is prime. P19' to file. It also prints 'Input is composite. C19' to file. Now to modify it so it prints just the actual number. After all, a file full of hundreds of thousands of lines of 'Input is prime/composite. P/C19' doesn't really do any good. :)

 Similar Threads Thread Thread Starter Forum Replies Last Post ldesnogu Computer Science & Computational Number Theory 11 2015-10-28 12:54 yavanna87 YAFU 4 2011-11-09 06:02 davidknippers Msieve 2 2011-10-27 11:44

All times are UTC. The time now is 08:12.

Wed Jan 27 08:12:32 UTC 2021 up 55 days, 4:23, 0 users, load averages: 4.44, 4.35, 4.45