Where is problem:
Code:
echo $block_new | awk --re-interval '{sub("'$hd'","'$uuid'","g") } $0' |
Awk sub command:
Code:
sub(regexp, replacement [, target]) Assuming you wish to do a global substitution (ie the "g" in your code), you can use: Code:
gsub(regexp, replacement [, target]) |
Quote:
Edit: How should be the regexp? Code:
/hd\\(0,2\\)/ Code:
/hd\(0,2\)/ awk: warning: escape sequence `\(' treated as plain `(' Edit I think that the double escaped backslash should be ok: Code:
hd=${hd//(/\\\\(}; # left bracket escape Code:
hd=${hd//(/\\(}; # left bracket escape Edit: But through ... nothing been replaced :-/ The block output still looks like: Code:
title Sata Mandriva kernel (hd0,2)/boot/vmlinuz BOOT_IMAGE=linux root=UUID=eab515e9-bc3e-4024-9f01-55fddaa0fb1c resume=UUID=e12487ff-6d6f-44c4-9e03-33f545b3b798 splash=silent vga=788 initrd (hd0,2)/boot/initrd.img |
So now you are putting UUID at the front of "/boot/vmlinuz"?
Again I would ask if you have tested that this will actually work, ie is having UUID there plausible, have you tested it? This worked for me without errors: Code:
echo "(hd0,2)/boot/vmlinuz" | awk 'gsub(/\(hd0,2\)/,"uuid")' |
Quote:
I didn't test. Never mind. Grub boot manager has a editor to change boot item before booting. Problem is elsewhere. NOT hd(0,2) BUT (hd0,2) - my fault! |
Quote:
|
One more problem in the regex replace. This is the effect: UUID=-4033-55
Code:
++ echo title Sata Mandriva kernel '(hd0,2)/boot/vmlinuz' |
Quote:
|
Quote:
EDIT: but none of these was credible in context :hattip: |
Quote:
Code:
"UUID=eab515e9-bc3e-4024-9f01-55fddaa0fb1c" On the other hand not nearly as confusing as the czech in some of your posts :) |
OK. Now I try to assign the $block_new back to the content:
Code:
content[$i]=$block_new; Code:
title Sata Mandriva kernel (hd0,2)/boot/vmlinuz BOOT_IMAGE=linux root=(hd0,2) resume=UUID=e12487ff-6d6f-44c4-9e03-33f545b3b798 splash=silent vga=788 initrd (hd0,2)/boot/initrd.img But in real, $block_new should be placed to content[0] |
I think you better have a look at some bash programming sites and how arrays work.
http://tldp.org/LDP/abs/html/arrays.html |
Well this works fine
Code:
echo ${content[*]}; |
Correct ;)
|
I did this:
If uuid is not found in blkid list, then: Code:
echo "Enter device:"; echo "Pattern: (hd0,0)"; read hd |
All times are GMT -5. The time now is 07:50 PM. |