How to edit a file from a Mac OS X command prompt?

How to open and edit a file on the command line? I tried using the command open:

sudo open -e /etc/apache2/extra/httpd-vhosts.conf

but the file Locked, and I can’t change anything.

enter image description here

I need to edit a lot of text and use nanoor vimnot very convenient.

+4
source share
3 answers

I suspect this is due to the fact that the resolution is for the command open, and not just for TextEdit.

, , SublimeText (sudo subl /path/to/file) TextMate (sudo mate /path/to/file). vi nano:-)

, TextEdit, , , .

+4

- , :

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
+2
sudo open -a TextEdit /etc/apache2/extra/httpd-vhosts.conf
+1
source

All Articles