LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-05-2021, 11:16 PM   #1
essahar
LQ Newbie
 
Registered: Jun 2006
Distribution: Red Hat Enterprise Linux
Posts: 12

Rep: Reputation: 0
sed to edit grub.cfg


Hello, Is there a way using sed command to delete all menuentry title in grub. the section should be

Quote:
menuentry title OS version ...
{ kernel and initial ramdisk parameter line1
kernel and initial ramdisk parameter line2
...
...
}
I want to delete the all line menuentry and what is after between the brackets
 
Old 01-06-2021, 01:08 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,142

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Of course there is a way - several probably.

Why do you want to ?. Do you know the potential consequences ?. If you break grub your system usually becomes unbootable. That is your responsibility, not anyone here who may have helped.
 
Old 01-06-2021, 01:44 AM   #3
essahar
LQ Newbie
 
Registered: Jun 2006
Distribution: Red Hat Enterprise Linux
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by syg00 View Post
Of course there is a way - several probably.

Why do you want to ?. Do you know the potential consequences ?. If you break grub your system usually becomes unbootable. That is your responsibility, not anyone here who may have helped.

I know what I'm doing I'll remove all the old entries then use the command new-kernel-pkg to add customs one with special kernel option and title. I have removed these entries manually and it is working.
 
Old 01-06-2021, 02:20 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,142

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Quote:
Originally Posted by essahar View Post
I know what I'm doing
In which case I'll desist.
 
1 members found this post helpful.
Old 01-06-2021, 02:46 AM   #5
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,677

Rep: Reputation: Disabled
Your profile says RHEL, but it shows the Ubuntu logo. In RHEL, the standard helper tool to deal with GRUB configuration from a shell script is grubby.

Last edited by shruggy; 01-06-2021 at 03:09 AM.
 
Old 01-06-2021, 04:12 AM   #6
essahar
LQ Newbie
 
Registered: Jun 2006
Distribution: Red Hat Enterprise Linux
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by shruggy View Post
Your profile says RHEL, but it shows the Ubuntu logo. In RHEL, the standard helper tool to deal with GRUB configuration from a shell script is grubby.
I'm using RedHat and I need a command line like sed to be used in a script not a graphical tool
 
Old 01-06-2021, 04:20 AM   #7
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,677

Rep: Reputation: Disabled
It's not a graphical tool. Have you checked its manpage?

Last edited by shruggy; 01-06-2021 at 08:06 AM.
 
Old 01-06-2021, 08:00 AM   #8
petelq
Member
 
Registered: Aug 2008
Location: Yorkshire
Distribution: openSUSE(Leap and Tumbleweed) and a (not so) regularly changing third and fourth
Posts: 627

Rep: Reputation: Disabled
Quote:
Originally Posted by essahar View Post
I'm using RedHat and I need a command line like sed to be used in a script not a graphical tool
You can use chmod to remove the x from all the files in /etc/grub.d/ that you don't want in grub.cfg.
I have a script that does this for everything then puts it back for the ones I want. I just want 00_header and 90_persistent (or you could include 40_custom).
I do this whenever there is a grub update.
I probably should point out I still have mbr bootloading.

Last edited by petelq; 01-06-2021 at 08:03 AM.
 
Old 01-06-2021, 09:51 AM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Wouldn't it be better to see how grub generates grub.cfg in the first place, and try to keep it from doing that?

Just my €

 
Old 01-06-2021, 11:31 AM   #10
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,677

Rep: Reputation: Disabled
@OP. Is this your thread on CentOS forums?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GRUB menu not getting updated even after changing /boot/grub/grub.cfg KNSI Linux From Scratch 4 06-20-2018 09:13 PM
GRUB menu not getting updated even after changing /boot/grub/grub.cfg KNSI Linux - Newbie 6 06-20-2018 01:54 PM
Files in /etc/grub.d not included in /boot/grub/grub.cfg. stf92 Slackware 21 05-27-2018 04:38 PM
Infinite Grub Loop: GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB GRUB... beeblequix MEPIS 2 11-02-2013 10:56 PM
[SOLVED] how to the give path of the part.cfg file in %include command in ks.cfg. YOGESHAS87 Linux - Newbie 2 01-11-2011 04:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration