Hello!
I've a config file like this :
Code:
[disks]
/dev/sda1 1 1275 83
/dev/sda2 1276 1406 82
/dev/sda3 1407 19929 8e
[swap]
...
My script have to read this file and use fdisk to recreate my partitions.
Here is my code with awk :
Code:
awk '/\[disks\]/ {
getline ;
while ($0 !~ /^\[.*/) {
if ($0 != "" ) {
device=$0;
gsub(/(\/dev\/[^0-9]*)([0-9]+).*/, "device=\1=\2=", device) ;
print device;
}
getline
}}' save.conf
Here is my result:
Code:
device===
device===
device===
I would like to separate the number of the partition and the device.
In my test, i would like to have:
device=/dev/sda=1
device=/dev/sda=2
device=/dev/sda=3
Is anyone could help me to understand my mistake?
Many thanks!