![]() |
![]() |
#1 |
Dec 2011
After milion nines:)
23·7·29 Posts |
![]()
Under Linux, in same directory I have two files, One is file a. txt and second is b.txt
So I need script that will read number of lines in a.txt and divide it with number of lines in b.txt and *100 to get percentage. |
![]() |
![]() |
![]() |
#2 |
Mar 2019
3×109 Posts |
![]()
How about something like:
Code:
$ echo 100*`wc -l a.txt | awk '{print $1}'`/`wc -l b.txt | awk '{print $1}'` | bc -l |
![]() |
![]() |
![]() |
#3 |
Dec 2011
After milion nines:)
162410 Posts |
![]() |
![]() |
![]() |
![]() |
#4 |
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
10,061 Posts |
![]()
echo `wc -l a` `wc -l b` |awk '{print $1*100/$3 "%"}'
|
![]() |
![]() |
![]() |
#5 |
"Oliver"
Sep 2017
Porta Westfalica, DE
17×79 Posts |
![]() |
![]() |
![]() |
![]() |
#6 |
Undefined
"The unspeakable one"
Jun 2006
My evil lair
6,689 Posts |
![]() |
![]() |
![]() |
![]() |
#7 | |
Dec 2011
After milion nines:)
23·7·29 Posts |
![]()
As always , bingo! :)
Thanks But I wrote the question a little clumsily :( ( my miastake) File a has always same content (only number is changed) (example) Quote:
I need some way to extract only number from file a in this case 193 and divide it with second value. I try with grep, but grep remove line, and since it is all in one line and that will not be changed ,grep is no use for me :( Any suggestions? |
|
![]() |
![]() |
![]() |
#8 |
Dec 2011
After milion nines:)
162410 Posts |
![]() |
![]() |
![]() |
![]() |
#9 |
Mar 2019
3×109 Posts |
![]() |
![]() |
![]() |
![]() |
#10 | |
Dec 2011
After milion nines:)
23·7·29 Posts |
![]() Quote:
Dont think that I just have some idea and post my question here without any try before. Linux is new OS to me,so I learn when I have time. Maybe my question are silly to you, but we all start at some point. |
|
![]() |
![]() |
![]() |
#11 |
Undefined
"The unspeakable one"
Jun 2006
My evil lair
6,689 Posts |
![]()
man echo
man awk man bc man grep man wc ... My favourite is man date |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
What percentage of users and/or total GHz days are being used for TF, P-1, DC, PRP, etc.? | piforbreakfast | PrimeNet | 10 | 2022-06-13 02:51 |
Mechanics of DC instead of LL percentage | Fred | PrimeNet | 1 | 2016-02-29 02:19 |
Fines based on a percentage of net worth | jasong | jasong | 30 | 2013-06-06 07:20 |
Bug in P-1 completion percentage report | NBtarheel_33 | Software | 3 | 2010-05-21 16:47 |
Modifying Percentage-Done Display? | Primeinator | Software | 4 | 2005-03-15 05:32 |