任何人都可以帮我在行尾添加条目。
这是linux os。
以下是文件/boot/grub2/grub.cfg
的内容### BEGIN /etc/grub.d/10_linux ###
menuentry 'Red Hat Enterprise Linux Server (3.10.0-327.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-75a4fe9b-ade6-4db0-a19c-e2dce64b4f2f' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 0ee3bceb-d7b7-4e56-ae16-a17ed5f395ea
else
search --no-floppy --fs-uuid --set=root 0ee3bceb-d7b7-4e56-ae16-a17ed5f395ea
fi
linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=UUID=75a4fe9b-ade6-4db0-a19c-e2dce64b4f2f ro crashkernel=auto rhgb quiet LANG=en_US.UTF-8
initrd16 /initramfs-3.10.0-327.el7.x86_64.img
}
menuentry 'Red Hat Enterprise Linux Server (0-rescue-3b0570b9c0c44fd7b8426ed7d80f55ff) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-3b0570b9c0c44fd7b8426ed7d80f55ff-advanced-75a4fe9b-ade6-4db0-a19c-e2dce64b4f2f' {
load_video
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 0ee3bceb-d7b7-4e56-ae16-a17ed5f395ea
else
search --no-floppy --fs-uuid --set=root 0ee3bceb-d7b7-4e56-ae16-a17ed5f395ea
fi
linux16 /vmlinuz-0-rescue-3b0570b9c0c44fd7b8426ed7d80f55ff root=UUID=75a4fe9b-ade6-4db0-a19c-e2dce64b4f2f ro crashkernel=auto rhgb quiet
initrd16 /initramfs-0-rescue-3b0570b9c0c44fd7b8426ed7d80f55ff.img
}
我需要在该行的末尾添加条目" text1"和" text2"。
linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=UUID=75a4fe9b-ade6-4db0-a19c-e2dce64b4f2f ro crashkernel=auto rhgb quiet LANG=en_US.UTF-8 text1 text2
编辑后,我的文件应如下所示:
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Red Hat Enterprise Linux Server (3.10.0-327.el7.x86_64) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-75a4fe9b-ade6-4db0-a19c-e2dce64b4f2f' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 0ee3bceb-d7b7-4e56-ae16-a17ed5f395ea
else
search --no-floppy --fs-uuid --set=root 0ee3bceb-d7b7-4e56-ae16-a17ed5f395ea
fi
linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=UUID=75a4fe9b-ade6-4db0-a19c-e2dce64b4f2f ro crashkernel=auto rhgb quiet LANG=en_US.UTF-8 text1 text2
initrd16 /initramfs-3.10.0-327.el7.x86_64.img
}
menuentry 'Red Hat Enterprise Linux Server (0-rescue-3b0570b9c0c44fd7b8426ed7d80f55ff) 7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-3b0570b9c0c44fd7b8426ed7d80f55ff-advanced-75a4fe9b-ade6-4db0-a19c-e2dce64b4f2f' {
load_video
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 0ee3bceb-d7b7-4e56-ae16-a17ed5f395ea
else
search --no-floppy --fs-uuid --set=root 0ee3bceb-d7b7-4e56-ae16-a17ed5f395ea
fi
linux16 /vmlinuz-0-rescue-3b0570b9c0c44fd7b8426ed7d80f55ff root=UUID=75a4fe9b-ade6-4db0-a19c-e2dce64b4f2f ro crashkernel=auto rhgb quiet
initrd16 /initramfs-0-rescue-3b0570b9c0c44fd7b8426ed7d80f55ff.img
}
答案 0 :(得分:2)
使用 sed 表达式:
sed '\~linux16 /vmlinuz-3\.10\.0-327\.el7\.x86_64~{s/$/ text1 text2/;}' /boot/grub2/grub.cfg