bash 附加到 /etc/apt/sources.list
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1584066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Append to /etc/apt/sources.list
提问by RyanScottLewis
I'm creating some scripts to streamline application installations and I need to append to the end of /etc/apt/sources.list
我正在创建一些脚本来简化应用程序安装,我需要附加到 /etc/apt/sources.list 的末尾
This code below append to files in ~ but not in /etc/apt/
下面的代码附加到 ~ 中的文件,但不在 /etc/apt/ 中
echo "deb http://ppa.launchpad.net/person/ppa/ubuntu karmic main" >> /etc/apt/sources.list
@meder
@meder
I have tried these following commands with no luck:
我尝试了以下命令但没有成功:
sudo echo "deb http://ppa.launchpad.net/person/ppa/ubuntu karmic main" >> /etc/apt/sources.list
#===---
sudo sh "echo 'deb http://ppa.launchpad.net/person/ppa/ubuntu karmic main' >> /etc/apt/sources.list"
回答by ephemient
This will work:
这将起作用:
sudo sh -c "echo 'deb http://ppa.launchpad.net/person/ppa/ubuntu karmic main' >> /etc/apt/sources.list"
However, instead of editing /etc/apt/sources.list, it is simpler to add a new *.listfile to /etc/apt/sources.list.d.
但是,与编辑 相比/etc/apt/sources.list,将新*.list文件添加到/etc/apt/sources.list.d.
For example,
例如,
echo 'deb http://ppa.launchpad.net/person/ppa/ubuntu karmic main' >/tmp/myppa.list sudo cp /tmp/myppa.list /etc/apt/sources.list.d/ rm /tmp/myppa.list
回答by meder omuraliev
make sure to have a backup file
确保有备份文件
echo "foo" | sudo tee -a /etc/apt/sources.list
However, I would reallyrecommend you create a new .list and then use this method to append, store it in /etc/apt/sources.list.d/
但是,我真的建议您创建一个新的 .list,然后使用此方法进行附加,将其存储在/etc/apt/sources.list.d/

