Iho*_*huk 10 macos command-line text-editor
如何在命令行中打开和编辑文件?我试着使用命令open
:
sudo open -e /etc/apache2/extra/httpd-vhosts.conf
Run Code Online (Sandbox Code Playgroud)
但文件是Locked
,我不能改变任何东西.
我需要编辑很多文本并使用nano
或vim
不是很方便.
Sin*_*rpa 10
sudo open -a TextEdit /etc/apache2/extra/httpd-vhosts.conf
Run Code Online (Sandbox Code Playgroud)
我怀疑这是因为权限提升是针对open
命令的,而不是TextEdit本身.
您应该使用不同的编辑器,可以从命令行中正确运行其二进制文件,如SublimeText(sudo subl /path/to/file
)或TextMate(sudo mate /path/to/file
).或者只是吮吸它并使用vi
或nano
:-)
如果你要做很多这类事情,TextEdit可能是最不受欢迎的编辑器.
编辑这些锁定文件的最简单方法是复制它们,编辑副本,然后替换文件:
cp /etc/apache2/extra/httpd-vhosts.conf ~/httpd-vhosts.conf
open ~/httpd-vhosts.conf
sudo mv /etc/apache2/extra/httpd-vhosts.conf /etc/apache2/extra/httpd-vhosts.conf.bkup
sudo mv ~/httpd-vhosts.conf /etc/apache2/extra/httpd-vhosts.conf
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
56152 次 |
最近记录: |