1

My debian os:

cat   /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye

There is the code to calculate codes written by perl in Debian woody, calculate code in os

For example, in Debian woody it is around 400-500 Mbs, try this:

size=0
for i in `grep -A 1 -B 1 "^Section: base" /var/lib/dpkg/available | grep -A 2 "^Priority: required" |grep "^Installed-Size" |cut -d : -f 2
`; do size=$(($size+$i)); done
echo $size
 47762

I copy all codes and execute in my os :

debian@debian:~$ size=0
debian@debian:~$ for i in `grep -A 1 -B 1 "^Section: base" /var/lib/dpkg/available |
  grep -A 2 "^Priority: required" |grep "^Installed-Size" |cut -d : -f 2
  `; do size=$(($size+$i)); done
debian@debian:~$ echo $size
0

Why the size is zero?

1 Answer 1

2

wrong code

If I follow your link, the code is:

for i in /bin/* /sbin/* /usr/bin/* /usr/sbin/*; do
    [ -f $i ] && {
        type=`file $i | grep -il perl`
        [ -n "$type" ] && echo $i;
    }
done

Moreover, in your attempt (see upper), you are trying to grep the base section from the file, and like on my debian, this section isn't present there, so zero result is normal.

Solution

#!/bin/bash

size=0
for i in /bin/* /sbin/* /usr/bin/* /usr/sbin/*; do
    [[ -x $i ]] &&
    file -i $i |
    grep -q perl &&
    ds=$(du $i | awk '{print $1}')
    ((size+=ds))
done
echo "$((size/1024)) MiB"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .