'Added scripts to AWK'

This commit is contained in:
Arkadiusz Hypki 2024-03-21 12:10:49 +01:00
parent 289c9d8f7d
commit dc24ee47b2
2 changed files with 34 additions and 0 deletions

16
04_AWK/4.awk Normal file
View File

@ -0,0 +1,16 @@
BEGIN {
sum = 0.0;
}
{
if ($2 > 40) {
print $1;
}
sum += $2;
}
END {
print "sum of population", sum;
}

18
04_AWK/5.awk Normal file
View File

@ -0,0 +1,18 @@
BEGIN {
sum = 0.0;
}
{
if ($1 != "#") {
sum += $2;
if ($2 > 40.0) {
print "Country ", $1, "has", $2, "mln people";
}
}
print "Nr of columns", NF;
}
END {
print "Total population ", sum;
}