### Issue:
Every now and then I need to do simple arithmetic in a command-line environment. E.G. given the following output:
Disk /dev/sdb: 256GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 106MB 105MB fat32 hidden, diag
2 106MB 64.1GB 64.0GB ext4
3 64.1GB 192GB 128GB ext4
5 236GB 256GB 20.0GB linux-swap(v1)
What's a simple way to calculate *on the command line* the size of the unallocated space between partition 3 and 5?
## What I've tried already:
## bc
bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
236-192
44
quit
where the bold above is all the stuff I need to type to do a simple 236-192
as bc 1+1
echoes File 1+1 is unavailable.
## expr
expr 236 - 192
where I need to type spaces before and after the operator as expr 1+1
just echoes 1+1
.
Asked by Fabby
(5549 rep)
Nov 6, 2018, 02:33 PM
Last activity: Jul 14, 2023, 10:29 PM
Last activity: Jul 14, 2023, 10:29 PM