-4

I am having a script file for disk usage and I am getting the following errors:

$ DISKTOTAL=$(df -m |column -t |awk '{print $2}' |tail -n +2|awk '{Total=Total+$1} END{print Total}')
df: '/var/lib/ureadahead/debugfs/tracing': No such file or directory
$ DISKUSAGE=$(df -m |column -t |awk '{print $3}' |tail -n +2|awk '{Total=Total+$1} END{print Total}')
df: '/var/lib/ureadahead/debugfs/tracing': No such file or directory
$ DISKUSAGEPERCENT=$(echo "$DISKUSAGE / $DISKTOTAL * 100.0"|bc -l)
-bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: Permission denied

It also gives this error while executing the script:

-bash: line 7: bc: command not found

Why is it not recognizing the bc command in my DISKUSAGEPERCENT command?

1 Answers1

0

Try installing bc:

sudo apt install bc
Artur Meinild
  • 26,018
  • the user cannot install anything, is there any other method possible? – Praveen Kumar Nov 17 '22 at 10:29
  • 1
    No? For an application to work it has to be installed. That hopefully shouldn't be a surprise??? – Artur Meinild Nov 17 '22 at 10:30
  • praveen.kumar@MUM:~$ sudo apt install bc [sudo] password for praveen.kumar: praveen.kumar is not in the sudoers file. This incident will be reported. praveen.kumar@MUM:~$ apt install bc E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? praveen.kumar@MUM:~$ – Praveen Kumar Nov 17 '22 at 10:32
  • Ask the administrator to install the application. – Artur Meinild Nov 17 '22 at 10:33
  • let me check whether thats possible – Praveen Kumar Nov 17 '22 at 10:33