Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am following this tutorial to correctly execute Aptana Studio on my Ubuntu 14.04:

So I have installed the Oracle JRE and finnally I have create this file that have to execute Aptana:


export UBUNTU_MENUPROXY=0 /home/andrea/Programmi/Aptana_Studio_3/AptanaStudio3

The problem is that when I try to execute this script with my shell I obtain the following error message:

andrea@andrea-virtual-machine:~/Programmi/Aptana_Studio_3$ sudo sh 1: !/bin/bash: not found 3: export: /home/andrea/Programmi/Aptana_Studio_3/AptanaStudio3: bad variable name

Why? What am I missing? How can I fix this issue?

share|improve this question
Just add an 'Hash' (#) before !/bin/bash, so it must be #!/bin/bash, It's an convention. This might help you! – Sat93 Aug 11 '14 at 17:59

There are two errors. In short, this is the particular fix I would suggest (details follow):

UBUNTU_MENUPROXY=0 /home/andrea/Programmi/Aptana_Studio_3/AptanaStudio3

Bad Hashbang Line

As Shutupsquare says, your hashbang line (technical details) should start with a #! rather than just !.

That is causing the first of your two error messages, and will prevent your script from being run as ./, but is not the reason your script is failing to run AptanaStudio3 (because the hashbang line is not required for sh calling syntax).

By the way, when you run sh, it runs your script with sh as the interpreter. But with the hashbang line #!/bin/bash, running ./ would run your script with bash as the interpreter. This script does not in any way depend on the advanced features of bash, and while bash's additional memory usage is almost certainly insignificant for this application, you may still wish to write the hashbang line so ./ runs the script with sh:


Incorrect Use of export

The main problem, which is causing your second error message and is the reason AptanaStudio3 fails to run, is that you're using export incorrectly. The export command does not run commands. So your command is being interpreted as an environment variable itself.

  • export can set and export an environment variable:

    export NAME=value
  • export can also export an environment variable (with whatever its current value is):

    export NAME

export does not accept NAME=value command or NAME command syntax, however.

Assuming your goal is to run the command /home/andrea/Programmi/Aptana_Studio_3/AptanaStudio3 with the UBUNTU_MENUPROXY variable defined and set to 0, you should just drop the word export altogether:

UBUNTU_MENUPROXY=0 /home/andrea/Programmi/Aptana_Studio_3/AptanaStudio3

That is the standard way to run a command with a modified environment, from a shell.

The purpose of export is to export variables into the environments of all subsequently launched child processes (i.e., every command run from your script). So running export UBUNTU_MENUPROXY=0 on its own line followed by the AptanaStudio3 command, as Shutupsquare suggests, will work, and have the same effect, and is a perfectly good and acceptable way to do it.

I prefer the way I've suggested above (without export) because:

  • Semantically, your goal is not to export anything, but rather to run a single command with a modified environment. Using export may cause confusion to others reading your script (or to yourself later), and as a secondary consideration is arguably less elegant.
  • With export, you need two commands; using the way without it, you need only one.

Optional reading: the env command works (sort of) the way you were trying to use export

Finally, there is a command that accepts NAME=value command syntax. This command is env. There's no reason to use it in this shell script--its function, in that basic usage, is to provide (part of) the power of a shell in running a command with a modified environment, and you already have that power.

However, under some circumstances, outside of shell scripting, you may find you need to set an environment variable for a command and run that command (and do those things in a single command). In contexts where just using the line VARIABLE=value command is not supported, you can use:

env VARIABLE=value command

You don't need that here though. All Bourne-style shells (e.g., sh, dash, bash, ksh, zsh) support VARIABLE=value command.

share|improve this answer

Should be #!/bin/bash. I also think that you should have a newline at the end of export UBUNTU_MENUPROXY=0.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.