Created
May 6, 2015 09:01
-
-
Save fourdollars/07f6fcf51a5e98b09f89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
strip_spaces () { | |
GRUB_CMDLINE_LINUX_DEFAULT=$(echo "$GRUB_CMDLINE_LINUX_DEFAULT" | sed "s/ \+/ /g;s/^ *//g;s/ *$//g") | |
} | |
remove_parameters () { | |
for i in "$@"; do | |
GRUB_CMDLINE_LINUX_DEFAULT=$(echo "$GRUB_CMDLINE_LINUX_DEFAULT" | sed "s/$i//g") | |
done | |
strip_spaces | |
} | |
add_parameters () { | |
for i in "$@"; do | |
if ! echo "$GRUB_CMDLINE_LINUX_DEFAULT" | grep "$i" >/dev/null 2>&1; then | |
GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT $i" | |
fi | |
done | |
} | |
GRUB_CMDLINE_LINUX_DEFAULT="quiet abc def splash" | |
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"$GRUB_CMDLINE_LINUX_DEFAULT\"" | |
add_parameters quiet splash "acpi_osi=\"Windows 2013\"" zswap.enabled=1 | |
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"$GRUB_CMDLINE_LINUX_DEFAULT\"" | |
remove_parameters abc def | |
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"$GRUB_CMDLINE_LINUX_DEFAULT\"" | |
remove_parameters "acpi_osi=\"Windows 2013\"" zswap.enabled=1 | |
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"$GRUB_CMDLINE_LINUX_DEFAULT\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment