Help with kdump scripts

Hi I am trying hard to append a configuration file like
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-238.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-238.el5.img
i am trying to append a word called crashkernel in the line "kernel /vmlinuz-2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet" as that line is taken from command line parameter.

for eg: if i give -k=crashkernel=512M it should get appended in the above kernel line at the end of the line with double quotes. Please help.

Please use code tags as required by forum rules!

What is the problem? Where are you stuck?

Hi,
I want to add a word called <carshkernel> at the end of the line.

Thanks,
Tejes

This I understood. What is the problem? Where are you stuck?

i am using tail command to add a crashkernel but my requirement is i want to search the file if crash kernel is there if not then append at the end of the line,i am not able to search for the pattern crash kernel and append it.

awk can do that for you:

awk '/^kernel/ && !/crash/ {$0=$0 " \"-k=crashkernel=512M\""} 1' grub.conf

But this doesn't seem the right way to me - read the man grub-mkconfig page for correct grub handling.

Hi Rudic,
Thank you so much for helping me out,i am using RHEL 5.6 i wanted to use sed command for this could you please help me out.

Thanks,
Tejes

I'm pretty sure that with a little consideration and effort you'll find a sed solution of your own.