Using Cygwin how do I Open a file from Command line

Posted on 2009-04-18
Last Modified: 2013-11-15
Ok I am new to all of this and know very little about Linux/Unix. Just really using the program for SSH to our routers but figured what the heck lets have a little fun.  So I started reading and reading and I think I am starting to like this stuff but was trying to find the command or to see if this is possible; basically I want to open a file in its default application from command line.  Found a command "open"  tried it and got -bash: open: command not found.  So I know you experts would know any help and possible website where I can learn about the capabilities would be greatly helpful.
Question by:mdpsolutions
    LVL 40

    Assisted Solution

    opining a file (text) can be done with

    vi filename

    LVL 40

    Expert Comment

    LVL 12

    Assisted Solution

    The command shell in Cygwin is Bash, and like all Unix shells, it doesn't directly support the concept of associating a file type with a default application. I haven't seent the "open" command you're referring to. The normal technique is to create a shell script that contains a link to the appropriate executable in the first line with a specific format:

    #! /usr/bin/perl
    ... perl

    This can be saved in a file called "", and if it has the execute bit set in the file permissions, typing:


    will execute the perl program. Of course, this doesn't work for something like a gif image that needs to open a viewer.

    Unix (and I assume Cygwin) has a command called "file" that will identify the type of file. I suppose it would be possible to create an "open" script that checks the file type, and executes the appropriate command from a list of known associations.
    LVL 15

    Assisted Solution

    It depends on the application. Take notepad for example say you have a file abc.txt from the command line you can open it in notepad with:

    notepad  abc.txt

    In general you want to check the application documentation to see what command line options it supports.

    Cygwin is very useful to learn more google cygwin tips and tricks...
    LVL 3

    Accepted Solution

    When I deal with routers, I prefer using putty, it's free and less bloated for this specific purpose.

    However, you could always use the: "less" command to view file contents.

    In essence, that is the best way besides using the vi editor if you want to edit.

    Using the "less" command, you can then scroll up and down using the keyboard up and down arrows.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Article by: Rob
    Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
    Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
    Video by: Phil
    This video goes over how to configure and start a jail in FreeBSD.  This video is meant to supplement the article included with this course.
    After watching the Introduction to GIMP this tutorial will show you additional tools to use in GIMP.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now