Reputation: 2343
I would like to know the difference between these two lines :
sudo sed 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=3/' /etc/default/grub >/etc/default/grub
and
sudo sed -i 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=3/' /etc/default/grub
There seems to be a difference because the first returns a Permission denied error while the other doesn't.
Upvotes: 0
Views: 2155
Reputation: 18667
As @sarathi said, the -i
flag modifies the file in-place. The reason you're getting a permission denied error is because /etc/default/grub
is probably only modifiable by root.
Your first command:
sudo sed 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=3/' /etc/default/grub >/etc/default/grub
Runs sed
as a superuser, which doesn't do anything useful as sed
writes to its stdout. Then it tries to overwrite /etc/default/grub
as the current user, which is disallowed.
In the second command:
sudo sed -i 's/GRUB_TIMEOUT=10/GRUB_TIMEOUT=3/' /etc/default/grub
The file is modified by sed
itself, which is running as root.
Upvotes: 4