Sum the installed sizes of packages matching a substring
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I would like to get all the packages that contain the "nvidia" substring in their name, to sum up their size and print the total size in megabytes.
To do so I have written the following oneliner:
dpkg-query -Wf '$Installed-Sizet$Packagen' | sort -n | grep nvidia | awk -F' ' 'sum+=$1ENDprint sum/1024;'
But, how can I beautify it, make it as short as it is possible to be, keeping the functionality?
It is crooked-written for now, as you can see.
debian awk grep
New contributor
add a comment |Â
up vote
3
down vote
favorite
I would like to get all the packages that contain the "nvidia" substring in their name, to sum up their size and print the total size in megabytes.
To do so I have written the following oneliner:
dpkg-query -Wf '$Installed-Sizet$Packagen' | sort -n | grep nvidia | awk -F' ' 'sum+=$1ENDprint sum/1024;'
But, how can I beautify it, make it as short as it is possible to be, keeping the functionality?
It is crooked-written for now, as you can see.
debian awk grep
New contributor
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I would like to get all the packages that contain the "nvidia" substring in their name, to sum up their size and print the total size in megabytes.
To do so I have written the following oneliner:
dpkg-query -Wf '$Installed-Sizet$Packagen' | sort -n | grep nvidia | awk -F' ' 'sum+=$1ENDprint sum/1024;'
But, how can I beautify it, make it as short as it is possible to be, keeping the functionality?
It is crooked-written for now, as you can see.
debian awk grep
New contributor
I would like to get all the packages that contain the "nvidia" substring in their name, to sum up their size and print the total size in megabytes.
To do so I have written the following oneliner:
dpkg-query -Wf '$Installed-Sizet$Packagen' | sort -n | grep nvidia | awk -F' ' 'sum+=$1ENDprint sum/1024;'
But, how can I beautify it, make it as short as it is possible to be, keeping the functionality?
It is crooked-written for now, as you can see.
debian awk grep
debian awk grep
New contributor
New contributor
edited 4 hours ago
Goro
5,67552460
5,67552460
New contributor
asked 4 hours ago
Twissell
183
183
New contributor
New contributor
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
You can filter using dpkg-query
itself, which means you donâÂÂt need to output the package name, and you donâÂÂt need to sort either:
dpkg-query -Wf '$Installed-Sizen' '*nvidia*' | awk 'sum+=$1ENDprint sum/1024;'
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
You can filter using dpkg-query
itself, which means you donâÂÂt need to output the package name, and you donâÂÂt need to sort either:
dpkg-query -Wf '$Installed-Sizen' '*nvidia*' | awk 'sum+=$1ENDprint sum/1024;'
add a comment |Â
up vote
4
down vote
accepted
You can filter using dpkg-query
itself, which means you donâÂÂt need to output the package name, and you donâÂÂt need to sort either:
dpkg-query -Wf '$Installed-Sizen' '*nvidia*' | awk 'sum+=$1ENDprint sum/1024;'
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
You can filter using dpkg-query
itself, which means you donâÂÂt need to output the package name, and you donâÂÂt need to sort either:
dpkg-query -Wf '$Installed-Sizen' '*nvidia*' | awk 'sum+=$1ENDprint sum/1024;'
You can filter using dpkg-query
itself, which means you donâÂÂt need to output the package name, and you donâÂÂt need to sort either:
dpkg-query -Wf '$Installed-Sizen' '*nvidia*' | awk 'sum+=$1ENDprint sum/1024;'
answered 4 hours ago
Stephen Kitt
148k22324393
148k22324393
add a comment |Â
add a comment |Â
Twissell is a new contributor. Be nice, and check out our Code of Conduct.
Twissell is a new contributor. Be nice, and check out our Code of Conduct.
Twissell is a new contributor. Be nice, and check out our Code of Conduct.
Twissell is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472550%2fsum-the-installed-sizes-of-packages-matching-a-substring%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password