Question: I know, I just can hit `Super`+`A` to see all installed apps in Ubuntu, but I need a command to list their names. The command

```
dpkg --get-selections | awk '{print $1}'

```

is also not an option because it shows all installed packages and it contains drivers, kernels and libraries.

Answer: 
I came up with this answer for people who wants to use bash in a good way. It's clear that the answer of the question is related to the listing of the files from `/usr/share/applications`, but the problem is that [`ls` command shouldn't be parsed ever](http://mywiki.wooledge.org/ParsingLs). In the past, I was doing the same mistake, but now I learned that the best way is to use a `for` loop to iterate over the files, even if I must use some more keys from my precious keyboard:

```
for app in /usr/share/applications/*.desktop; do echo "${app:24:-8}"; done

```

I also used in the previous command [string manipulation](http://tldp.org/LDP/abs/html/string-manipulation.html) operations: removed from `app` first 24 characters which are `/usr/share/applications/` and last 8 characters which are `.desktop`.

---

**Update:**

Another place where you can find applications shown by the Dash is `~/.local/share/applications/*.desktop`. So you need to run the following command as well:

```
for app in ~/.local/share/applications/*.desktop; do echo "${app:37:-8}"; done

```

To unify the previous two commands, you can use:

```
for app in /usr/share/applications/*.desktop ~/.local/share/applications/*.desktop; do app="${app##/*/}"; echo "${app::-8}"; done

```
Not sure why most of the answers posted involves extracting the filename of .desktop shortcuts. Your .desktop shortcut filename can be anything but what matters is the `Name` field inside the shortcut file. If you want to build the list of installed application names showing in Dash, just "grep" that field under `[Desktop Entry]`

Rudimental code, with bash

```bsh
#!/bin/bash

for file in /usr/share/applications/*.desktop;
do
    while IFS== read -r key val
    do
        if [[ -z $key ]]; then
            continue
        else
            if [[ $key =~ ^\[Desktop\ Entry ]]; then
                interesting_field=1
            elif [[ $key =~ ^\[ ]]; then
                interesting_field=0
            fi
        fi
        [[ $interesting_field -eq 1 ]] && [[ $key == "Name" ]] && echo $val
    done < $file
done

```

But this does not take into account shortcuts that are hidden from being showed in Dash. Someone with better understand of .desktop spec might want to further expand this code to exclude those kinda of shortcuts

**Edit : another attempt, with Python**

```py
#!/usr/bin/python

from os import listdir
from os.path import isfile, join
import ConfigParser

SHORTCUTDIR = "/usr/share/applications/"

shortcuts = [ file for file in listdir(SHORTCUTDIR) if isfile(join(SHORTCUTDIR, file)) and file.endswith(".desktop") ]
dash_shortcuts = []

for f in shortcuts:
    c = ConfigParser.SafeConfigParser()
    c.read(SHORTCUTDIR + f)

    try:
        if c.getboolean('Desktop Entry', 'NoDisplay') is True:
            continue
    except ConfigParser.NoOptionError:
        pass

    try:
        if "unity" in c.get('Desktop Entry', 'NotShowIn').lower():
            continue
    except ConfigParser.NoOptionError:
        pass

    try:
        if "unity" not in c.get('Desktop Entry', 'OnlyShowIn').lower():
            continue
    except ConfigParser.NoOptionError:
        pass

    dash_shortcuts += [ c.get("Desktop Entry", "Name") ]

for s in sorted(dash_shortcuts, key=str.lower):
    print s

```