How do I divide in the Linux console?

后端 未结 12 2005
情话喂你
情话喂你 2020-12-25 10:41

I have to variables and I want to find the value of one divided by the other. What commands should I use to do this?

12条回答
  •  盖世英雄少女心
    2020-12-25 11:02

    Something else you could do using raytrace's answer. You could use the stdout of another shell call using backticks to then do some calculations. For instance I wanted to know the file size of the top 100 lines from a couple of files. The original size from wc -c is in bytes, I want to know kilobytes. Here's what I did:

    echo `cat * | head -n 100 | wc -c` / 1024 | bc -l
    

提交回复
热议问题