Mailinglist Archive: opensuse (1445 mails)

< Previous Next >
[opensuse] bash - howto sudo echo X >> Y (sed?)
Guys,

I have an interesting question. I have a file that I need to append
information to that is owned by root. Initially I wanted to use echo:

sudo echo "X" >> y.txt

But, of course the echo has root privileges, but the redirection does not. So
then I though about sed. It works, but how do I tell sed to 'append to end of
file'?

The last word in the existing file is custompkgs, but that isn't guaranteed to
stay that way. As it sits, I can:

sudo sed -i '/\/custompkgs/s#$#\n\n[local]\nServer = file:///repo\n#'
$CHROOT/root/etc/repo.conf

How can I omit searching for a word and just tell sed to append at end of
file?

Or, how can I use echo or cat to do the same thing, but overcome the lack of
privilege on the >> ?

--
David C. Rankin, J.D.,P.E.
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >