MacOS open’s under Linux

MacOS has a nice “open” command that will open any document with any application from the command line. I hacked my own for Linux for a bash shell:

TEMP=`getopt -o a: -- "[email protected]"`
if [ $? != 0 ] ; then exit 1 ; fi
eval set -- "$TEMP"
while true ; do
case "$1" in
-a) COMMAND=$2 ; shift 2;;
--) shift ; break ;;
*)echo "should not happen" ; exit 1 ;;
if [ $COMMAND ]; then
nohup $COMMAND [email protected] > ~/.s1 2> ~/.s2 &
/usr/bin/xdg-open [email protected]

Published by

Daniel Lemire

A computer science professor at the University of Quebec (TELUQ).

4 thoughts on “MacOS open’s under Linux”

Leave a Reply to Daniel Lemire Cancel reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see