1 Dec 2023 |
| Husseinberg changed their display name from Saad Goodman to Husseinberg. | 20:11:12 |
| Husseinberg changed their profile picture. | 20:11:22 |
| Husseinberg changed their profile picture. | 20:11:31 |
enigma9o7 | anyone good at sed? I want a one-liner to edit /etc/default/grub that makes sure GRUB_DISABLE_OS_PROBER=false ; is there a way to do it so if there's already a GRUB_DISABLE_OS_PROBER line it makes sure it's not commented (remove # at beginning if exist) and if set to true, change it to false? | 21:28:07 |
enigma9o7 | I'm at the point I think the easiest way is just delete any line with GRUB_DISABLE_OS_PROBER then just add the line I want. | 21:28:48 |
enigma9o7 | But I realize that's not the best way to do it.... | 21:29:08 |
iam_tj | enigma9o7: echo "GRUB_DISABLE_OS_PROBER=yes" | sudo tee -a /etc/default/grub.d/local.cfg; sudo update-grub | 21:33:52 |
enigma9o7 | that can end up with multiple lines | 21:35:54 |
enigma9o7 | that's just adding it, not editing it. | 21:36:01 |
iam_tj | Tip: *.cfg files in /etc/default/grub.d/take precedence and so avoid having to edit /etc/default/grub` | 21:36:27 |
enigma9o7 | but yeah I'm at the point I think I'm just gunna use sed to remove existing line then add it back, could use tee like you said or just sed, either way. | 21:36:30 |
enigma9o7 | I was just trying to figure out a sed command to edit it, instead of delete and add a line, but it really makes no difference, just annoying me i coudln't figure it out the way i originally tried | 21:36:46 |
iam_tj | Notice I'm not writing the package-shipped file; do not need to edit it with sed... just drop additional file(s) in /etc/default/grub.,d/*.cfg and they'll be source ed after... order is lexical | 21:38:51 |
iam_tj | * Tip: *.cfg files in /etc/default/grub.d/ take precedence and so avoid having to edit/etc/default/grub\ | 21:39:30 |
enigma9o7 | I'll just sudo sed -i '/OS_PROBER/d' /etc/default/grub first I guess. | 21:39:45 |
iam_tj | The issue with editing it is, if grub-common/grub2-common are updated the upgrade requires you to decide which version to keep - the package version or your edits. By dropping files in grub.d you can avoid that | 21:42:23 |
iam_tj | * Notice I'm not writing the package-shipped file; do not need to edit it with sed... just drop additional file(s) in /etc/default/grub.d/*.cfg and they'll be source ed after... order is lexical | 21:44:07 |
iam_tj | sed -i 's/^\(GRUB_DISABLE_OS_PROBER\)=\(.*\)/\1=false/' /etc/default/grub | 21:48:34 |
enigma9o7 | sudo sed -i '/OS_PROBER/d' /etc/default/grub
sudo sed -i -e '$aDISABLE_OS_PROBER=false' /etc/default/grub ```
| 21:48:50 |
enigma9o7 | is what i have now | 21:48:52 |
enigma9o7 | * sudo sed -i '/DISABLE_OS_PROBER/d' /etc/default/grub
sudo sed -i -e '$aDISABLE_OS_PROBER=false' /etc/default/grub
| 21:56:30 |
enigma9o7 | I think I'm just gunna stick with that; what you suggested doesn't deal with it if it's commented already. | 21:57:12 |
enigma9o7 | Making it a one-liner confuses me and wasting my time :) | 21:57:36 |
iam_tj | So edit as appropriate; if it is commented then you need to match on the comment as well | 21:59:17 |
iam_tj | * sed -i 's/^#*\(GRUB_DISABLE_OS_PROBER\)=\(.*\)/\1=false/' /etc/default/grub | 22:02:54 |
enigma9o7 | well the point is i want it to cover if its commented or not :) | 22:04:33 |
enigma9o7 | If there's a hash at the begin, remove it. if set to true, change to false. | 22:04:46 |
enigma9o7 | I'd rather have done the inplace editing so that it doesn't change the position of the line in the file, the solution I posted above just puts the new line at the end. | 22:05:15 |
enigma9o7 | * I'd rather have done the inplace editing so that it doesn't change the position of the line in the file, the solution I posted above just deletes the old line and puts the new line at the end. | 22:05:30 |
iam_tj | I edited the one-liner to show how to match on a comment (or not) but not write a comment prefix | 22:06:15 |