Reputation: 11
I want to change a remote file. For this i use sed command. I have file with following content:
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX=/ankur
GRUB_DISABLE_RECOVERY="true"
So I want to append in this file.
I have tried this command:
sed -i 's+^GRUB_CMDLINE_LINUX.*+GRUB_CMDLINE_LINUX=/sharma+g' '/etc/default/grub.bak'
But it changed to value of GRUB_CMDLINE_LINUX. But I want to append sharma to it initial value.
So the sed command should give the below output for the above file.
expected output:
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX=/ankur sharma
GRUB_DISABLE_RECOVERY="true"
Upvotes: 0
Views: 77
Reputation: 133770
Could you please try following simple sed
once. Please use -i
option in case you want to place output into Input_file itself.
sed '/GRUB_CMDLINE_LINUX/s/$/ sharma/' Input_file
Upvotes: 5