Code: Select all
sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash zswap.enabled=1 zswap.zpool=z3fold zswap.compressor=lz4"/' /etc/default/grub
Code: Select all
sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash zswap.enabled=1 zswap.zpool=z3fold zswap.compressor=lz4"/' /etc/default/grub
Code: Select all
sudo sed -i s/\
'GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"'/\
'GRUB_CMDLINE_LINUX_DEFAULT="quiet splash zswap.enabled=1 zswap.zpool=z3fold zswap.compressor=lz4"'/\
/etc/default/grub
THX much - but one thing I am confused about is:AwesomeOpossum74 wrote: ⤴Mon Jan 24, 2022 9:34 pm How about:I recommend you verify it works on a test file before running it on your working grub file.Code: Select all
sudo sed -i s/\ 'GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"'/\ 'GRUB_CMDLINE_LINUX_DEFAULT="quiet splash zswap.enabled=1 zswap.zpool=z3fold zswap.compressor=lz4"'/\ /etc/default/grub
Code: Select all
compressor=lz4"'/\
Code: Select all
compressor=lz4"/' /etc/default/grub
THX - appreciate the explanation - not long winded at all and helpfulAwesomeOpossum74 wrote: ⤴Mon Jan 24, 2022 10:45 pm Normally things inside double quotes would be interpreted, like if you had a $variable. Stuff inside single quotes don't get interpreted, and are passed as is. Since the double quotes are inside the single quotes, the single quotes take precedence, and the double quotes will not be interpreted. Probably a long-winded and confusing explanation. Sorry about that.
Not actually testing this myself, but since the sed delimiter is slash (/), you could probably dispense with the single quotes, unless you later add slashes to the values.
Edit: How about this explanation: The single quotes force the double quotes to be interpreted as part of the string, rather than special characters to be functionally interpreted.
That is not mandatory. In this topic viewtopic.php?f=213&t=365559, I submitted this command :
Code: Select all
find $CustDir -name '*.cust' -exec sed -i 's|home/'$PrevUser'|home/'$USER'|g' {} +
Using s,,,g rather than your s|||g only as a (strong) personal preference...
Code: Select all
sed -i "s,/home/[^/]\+/,/home/$USER/,g" "$CustDir"/*.cust
THX - I think I am beginning to catch on . . . . albeit slowly.LittleScriptMan wrote: ⤴Tue Jan 25, 2022 7:48 am So, you can use other delimiters when it helps being more readable (the pipe and the comma prevented confusion with the delimiter slash and the slashes included in paths). Of course, you can keep on using slashes even when dealing with paths if the command is set to take the difference in account.
There is no hierarchy. You can use any except the backslash and the newline, even A,z, 4, £. Of course, the goal should still be better readability. Probably special characters with accents (french), tildes (spanish) or diaresis (swedish) would be problematic too. Never tried. Either the usual / or the pipe when already using slashes in the search or replace expressions worked fine for me, even if the comma may seem more different from the slash than the pipe with is somewhat a vertical slash.majpooper wrote: ⤴Tue Jan 25, 2022 2:02 pm I have been looking over a sed tutorial online - it shows basics commands and uses delimiters but really does not explain them in terms hierarchy if there is one . . . . or do you just use them interchangeably to suit one's preference and readability. I guess I will just have to experiment.