meaning of "'" (apostrophe) in terminal commands

The ' character is a very powerful character whenever used in any shell command. Basically the ' (apostrophe marks) disables all kinds of transformations or modifications. It would consider whatever is enclosed with the ' marks as a single entity i.e. a single parameter. Absolutely no sort of substitution or expansion would take place.

Example:

 $ echo '$HOME'

would produce at the output the string $HOME itself and would not print the path to your home directory. Since the single quotes prevents any sort of expansion, substitution and simple considers whatever to be present as a simple parameter in itself.

If you want to use the apostrophe as it is, you have to escape it:

 $ mkdir foo\'bar

 $ cd foo\'bar

If it is not escaped, it will wait for it's pair to be closed, like it happened in your first example.

So, corrected, your command will be:

 $ export foo\'bar=1

NOTE: As Milan Todorovic noticed, this will not be valid, because you cannot use apostrophe in this case.


Character ' is a special character. You use it to mark part of command line entry that won't be changed (e.g. no replacement for wildcards). For example:

$ ls 'bla*'
ls: cannot access bla*: No such file or directory

This means that argument for ls was bla* and not everything that begins with bla.

The reason why you get > character is because you must use one ' for opening and one ' for closing part that won't be changed.

If you want to use ' in folder names you must escape it like this: \'. So if you want to list folder named foo'bar you should type ls foo\'bar.

Oh, and I'm not sure if it is possible to use ' in environment variable names. I think that you cannot use export foo\'bar=1,

Hope this helps.