Need Command for Opening Files in Terminal

Discussion in 'macOS' started by Catfish Jones, Jun 25, 2006.

  1. Catfish Jones macrumors member

    Sep 22, 2005
    You'd think this was all pretty basic. It probably is. :(

    I'm trying to open/edit '/usr/local/php5/lib/php.ini' with TextWrangler through Terminal. The TextWrangler part isn't an absolute requirement. The directory exists and I'm assuming the file does as well. (No 404-esq errors during my fumblings and it was a standard installation of PHP5)

    Also, is there any way to browse through the above directory using the Finder's GUI? That would be nice...
  2. mkrishnan Moderator emeritus


    Jan 9, 2004
    Grand Rapids, MI, USA
    You'll like this.

    The command you're looking for is called "open." :D

    If you are in a directory,

    open .

    will open the directory in Finder. Specifying a folder either relatively or directly will also open it in Finder.

    open ~/documents

    Open will open any file in the default reader if the file is passed to it.

    open spreadsheet.xls

    Will launch Excel and open spreadsheet.xls, for instance. The only wrinkle for you is that TextWrangler may not be the default for opening .ini files. You can do this:

    open -a /applications/ file.ini

    Where you can replace the textwrangler part with the actual location and name of the app.

    Does that help? :)
  3. devman macrumors 65816


    Apr 19, 2004
    I'm no terminal expert but "open filename" will open a file with whatever app it is associated with.

    For the Finder use the menu item Go->Go to folder (SHIFT-CMD-G).
  4. Catfish Jones thread starter macrumors member

    Sep 22, 2005
    Thanks mkrishnan and devman. Works beautifully. I even figured out my global issue. I kept searching for things like "open file mac os x terminal" and wasn't getting any results. Replacing "mac os x terminal" with "unix" in my searches sure boosted the result count. :rolleyes:

    Hopefully that means no more stupid questions from me. :D

    Thanks again guys.
  5. mduser63 macrumors 68040


    Nov 9, 2004
    Salt Lake City, UT
    The open command will work, but I thought you might be interested to know that TextWrangler includes a command-line tool for opening files. You can install it by opening TextWrangler Preferences, going to the "Tools" section and then clicking "Install Command Line Tools". After you do that, you can type "edit name_of_file.txt" from Terminal to open any file in TextWrangler. I've actually never tried using that feature, but it is an advertised feature of TW.
  6. bobot macrumors newbie

    Nov 17, 2008

    If you're building nonlinear bayesian models, assembling vast databases or working towards an AI singularity, the unix/Linux crowd has lots to offer. The detail people go into is incredible, and I've learned a fair bit.

    I've been using linux it almost exclusively for about a year and a half and this is literally the first time I have found a straightforward, relevant answer to the question "How the hell do I open a file?"

    Don't get me wrong, I have listened to dozens of detailed explanations, which laboriously explain examples of every aspect of the commands, and cheerfully say "Now just open this file..."

    Unbelievable. Quite frankly, if it wasn't for the excellent and active support communities, I don't think it would be nearly as popular.

    Thank you SO much. I really appreciate it.
  7. drayon macrumors 6502

    Aug 20, 2007
    What is the solution to using the 'open' command on a filename such as '(te) tvseries - Season 2.torrent' ?? terminal reports file doesn't exist
  8. robbieduncan Moderator emeritus


    Jul 24, 2002
    You will need to put the file name in quotes

Share This Page