Score:-4

"-bash: line 7: bc: command not found" error in script

in flag

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?

Artur Meinild avatar
vn flag
Maybe because it isn't installed?
karel avatar
sa flag
Does this answer your question? [How do I install applications in Ubuntu?](https://askubuntu.com/questions/307280/how-do-i-install-applications-in-ubuntu)
pLumo avatar
in flag
Is this about Ubuntu, if so which version? `bc` is installed by default since I remember.
Score:0
vn flag

Try installing bc:

sudo apt install bc
Praveen Kumar avatar
in flag
the user cannot install anything, is there any other method possible?
Artur Meinild avatar
vn flag
No? For an application to work it has to be installed. That hopefully shouldn't be a surprise???
Praveen Kumar avatar
in flag
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:~$
Artur Meinild avatar
vn flag
Ask the administrator to install the application.
Praveen Kumar avatar
in flag
let me check whether thats possible
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.