Search code examples
bashls

bash scripting - what does "ls .." (ls with double dot) do?


My homework asked me to find what ls .. does.

I tried to search the internet but I couldn't find any answer to the question.

Does someone know what this command does?


Solution

  • .. is an entry in the current directory that refers to the parent of the current directory. It's not a special convention used just by ls. For example:

    $ cd /usr/bin
    $ pwd
    /usr/bin
    $ cd ..
    $ pwd
    /usr
    $ [ -d .. ] && echo "It's a directory"
    It's a directory
    $ stat ..
    <output specific to your installed version of stat>