gpt4 book ai didi

bash - 如何使用 bash 脚本获取分区的偏移量?

转载 作者:行者123 更新时间:2023-12-05 02:23:37 24 4
gpt4 key购买 nike

我可以使用 parted 找出图像的偏移量。

sudo parted -s image.img unit B print
Model: (file)
Disk /home/user/image.img: 107374182400B
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 2097152B 107374182399B 107372085248B primary ext4

例如,分区从2097152开始。

如何使用 bash 脚本获取 2097152

我或许可以解析输出,但也许有更合适的方法?

最佳答案

一个选项,将输出提供给

sudo parted -s image.img unit B print | 
awk '/^Number/{p=1;next}; p{gsub(/[^[:digit:]]/, "", $2); print $2}'

关于bash - 如何使用 bash 脚本获取分区的偏移量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20181695/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com