mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Linux

Reply
 
Thread Tools
Old 2015-07-12, 00:54   #1
pepi37
 
pepi37's Avatar
 
Dec 2011
After milion nines:)

101100011002 Posts
Default what I do wrong

results.txt
---------------------------------------------------------------------------
[Sat Jul 11 23:04:00 2015]
2*11^13355+1 is not prime. RES64: 2BC6AF8D47953C43. We8: 68566856,00000000
2*11^13356+1 is not prime. RES64: 27FF3175F85CE71C. We8: 68586858,00000000
2*11^13357+1 is not prime. RES64: 0FE8C886B553D211. We8: 685A685A,00000000
2*11^13359+1 is a probable prime! We8: 685E685E,00000000
---------------------------------------------------------------------------

clear
echo
echo " **** UP TIME **** "
echo " "
Quote:
to see does computer work all time
uptime | sed 's/^.* up \+\(.\+\), \+[0-9] user.*$/\1/'
echo " "

echo " **** PRP FOUND **** "
echo " "
Quote:
check is anywhere "prime!" and display it
grep -h 'prime!' /pepi/mprime/results.txt | cut -d"W" -f1
grep -h 'prime!' /pepi/res.txt | cut -d"W" -f1
grep -h 'prime!' /pepi/prp.txt | cut -d"W" -f1
echo " "

echo "COLLECTING RESULTS"
cat /pepi/mprime/results.txt >> res.txt
for fname in /pepi/mprime/results.txt
Quote:
collect results to file res.txt and delete results.txt
do
> $fname
done
echo "COLLECTING DONE "
echo " "

grep -h 'prime.' /pepi/res.txt | cut -d"W" -f1 > res.txt
Quote:
remove part of line I dont need
wc -l < /pepi/res.txt
Quote:
count lines in res.txt and display result
grep "!" /pepi/res.txt >> prp.txt
Quote:
copy line with "!" to file prp.txt
echo " "
echo NUMBER of PRIMES
wc -l prp.txt | cut -d "p" -f1
Quote:
counts number of lines in prp.txt and display result
sleep 2
exit


What I do wrong?
This is my script that collects results from file, remove part of lines, and wrote that in res.txt and prp.txt
And all is ok if there is data in "initial file"- results.txt, this script do exactly what I wont
But if results.txt is empty, then script also delete content of res.txt?
Why, where is error?
Thanks for any advice!

Last fiddled with by pepi37 on 2015-07-12 at 00:57
pepi37 is offline   Reply With Quote
Old 2015-07-12, 04:27   #2
Mark Rose
 
Mark Rose's Avatar
 
"/X\(‘-‘)/X\"
Jan 2013

3×977 Posts
Default

Code:
grep -h 'prime.' /pepi/res.txt | cut -d"W" -f1 > res.txt
The single > will always overwrite the file.

You could test if the file is empty at the beginning and exit or whatever:

Code:
if [[ ! -s /pepi/res.txt ]] ; then exit ; fi
Mark Rose is offline   Reply With Quote
Old 2015-07-12, 05:16   #3
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

3·29·83 Posts
Default

Or use ">>" (appends without overwriting)
Dubslow is offline   Reply With Quote
Old 2015-07-12, 08:10   #4
pepi37
 
pepi37's Avatar
 
Dec 2011
After milion nines:)

22·5·71 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Or use ">>" (appends without overwriting)
If I do that then number of lines id doubled in every checking, so that is not solution.
But I dont know why is doubling if initial file is empty.

Quote:
if [[ ! -s /pepi/res.txt ]] ; then exit ; fiT
his throw some error, so it doesnot work :(

Last fiddled with by pepi37 on 2015-07-12 at 08:10
pepi37 is offline   Reply With Quote
Old 2015-07-12, 09:13   #5
pepi37
 
pepi37's Avatar
 
Dec 2011
After milion nines:)

58C16 Posts
Default

I found where error was.
I must create temporary file and then delete it

grep -h 'prime.' /pepi/resu.txt | cut -d"W" -f1 >> results.txt
rm resu.txt

Now all is perfect!
Thanks for help!
pepi37 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Moore's Law wrong, or is it wrong-headed (6th time around) jasong jasong 12 2016-05-27 11:01
Am I doing it wrong? kracker PrimeNet 3 2012-07-01 22:35
something wrong with my RAM? ixfd64 Hardware 13 2010-07-17 20:49
Something is very wrong... RhymeBomb Information & Answers 7 2010-02-28 09:53
something wrong here? ixfd64 Lounge 2 2007-09-17 13:20

All times are UTC. The time now is 02:11.

Sat May 8 02:11:01 UTC 2021 up 29 days, 20:51, 0 users, load averages: 2.24, 1.83, 1.57

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.