Search code examples
bashterminalshls

How can I get rid of the ./ and ../ in the ls output


I want to remove the .. and . entry in the ls output. How ever, running

ls . | sed '/^\.\./d;/^\.\//d'

doesn't work for me (./ is still here) and I can't figure out why.


Solution

  • ls has -A option exactly for this purpose:

    ls -A
    

    From man ls:

    -A, --almost-all
                  do not list implied . and ..