Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Blogs
User Name


I leave notes here that I find particularly worth remembering myself.

Shortest command to calculate the sum of a column of output

Posted 06-02-2010 at 07:27 AM by bittner (Notes on Linux)

I had to calculate the Installed-Size for a .deb control file recently. Here is the solution I came up with:

dpkg-deb -c mypackage.deb | sed -e 's/.*root\s*//' -e 's/\s*2010-.*$//' | xargs | tr ' ' + | bc
What it does? The code tries to construct a calculation string and feeds it to the command line calculator bc as follows:
  1. use dpkg-deb to get the file size information out of the Debian package
  2. sed away all characters before and after the
LQ Newbie
Posted in Uncategorized
Views 4845 Comments 2 bittner is offline


All times are GMT -5. The time now is 07:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration