Mailinglist Archive: opensuse (1445 mails)

< Previous Next >
Re: [opensuse] bash - howto sudo echo X >> Y (sed?)
  • From: Anders Johansson <ajh@xxxxxxxx>
  • Date: Sun, 11 Mar 2012 21:56:07 +0100
  • Message-id: <2085807.o8qm5oFY1Z@carolin>
On Sunday 11 March 2012 15:27:25 David C. Rankin wrote:
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

sudo bash -c "echo X >> y.txt"

works. Or you can put the whole thing in a script and just do

sudo script.sh

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?

~> cat foo
foo
~> sed -ie '$a \bar' foo
~> cat foo
foo
bar

Anders
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
References