I have an .img file from which I would like to extract 2 values derived with fdisk, as strings in 2 variables.
fdisk -l /home/documents/image-of-sd-card.img
Disk /home/documents/image-of-sd-card.img: 14,84 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xc680d152
Device Boot Start End Sectors Size Id Type
/home/documents/image-of-sd-card.img1 8192 655359 647168 316M c W95 FAT32 (LBA)
/home/documents/image-of-sd-card.img2 655360 31115263 30459904 14,5G 83 Linux
The values I would need are the last unit from "Sector size" (512) and the End size of the second partition (31115263). How to achieve that? I would prefer a Bash based solution so that I could integrate this into an existing Shell script.
As an absolute beginner in Linux I just played around with some greb commands but to no avail.