My shell is bash. How can I get the output of ls to show directories with a trailing forward-slash? When I do ls in tcsh it gives the desired output. How can I get this to occur in bash without using any arguments?


  • 7
    Your shell isn't relevant here... man ls then scroll down to -p Commented Feb 23, 2016 at 0:00
  • @don_crissti See my edit to the question.
    – CJ7
    Commented Feb 23, 2016 at 0:23
  • @CJ7 - what is type ls output ? Maybe an alias ? Commented Feb 23, 2016 at 0:42
  • @don_crissti output is ls is a tracked alias for /bin/ls
    – CJ7
    Commented Feb 23, 2016 at 2:34

4 Answers 4


The simplest solution (as given already by @don_crissti in the comments) is:

ls -p

You can get a similar effect with:

ls -F

But that will add some other indicators as well:

Append a character to each file name indicating the file type. Also, for regular files that are executable, append *. The file type indicators are / for directories, @ for symbolic links, | for FIFOs, = for sockets, > for doors, and nothing for regular files.

Of course, you can make the string ls execute ls -p on the command line with an alias:

alias ls='ls -p'

That is temporal and could be erased with unalias ls.
Probably your tcsh has an active alias in place.

Which you can do by placing the command in ~/.bashrc or ~/.bash_aliases.

  • That last bit caught my attention. I've never seen or heard of a ~/.bash_aliases before; only ~/.bash_profile and/or ~.bashrc. Is it correct?
    – voices
    Commented Feb 29, 2016 at 8:58
  • 1
    @tjt263 It is a common practice to place all aliases in a special file sourced from bashrc. The contents may vary depending on your needs.
    – user79743
    Commented Feb 29, 2016 at 14:46
  • To keep colors: alias ls='ls --color=auto -p'
    – mkczyk
    Commented Mar 15, 2019 at 18:16

You can use -F, e.g.

$ /bin/ls -F
-/                                 diesel_folks                 grub                     presidents             user_mailer/
0/                                 dmStaffing/                  HJJJH/                   prime_scenarios   
# I'm using /bin/ls to make sure I run my system ls 
# (I actually have it aliased to add options automatically normally)
# Just read about your no argument requirement
# So you too could alias it, i.e.

alias ls='ls -F'

# Put it in your `.bashrc` or `.bash_aliases` file
  • Do you know why tcsh is giving me desired output and bash isn't?
    – CJ7
    Commented Feb 23, 2016 at 0:34
  • 1
    @CJ7 Because tcsh and bash use different configuration files (with different syntax). You presumably already have a similar alias in your .cshrc. Commented Feb 23, 2016 at 0:41
  • I tried making a .bashrc file in my home directory but it didn't work
    – CJ7
    Commented Feb 23, 2016 at 2:37
  • @CJ7, did you restart your shell after making that change? Commented Sep 26, 2017 at 6:43


   ls --classify


   ls --indicator-style=slash


   -F, --classify
          append indicator (one of */=>@|) to entries

   -p, --indicator-style=slash
          append / indicator to directories

The other answers more or less cover this, but I prefer GNU-style long options over BSD-style short options in Stack Overflow answers since they are more self-explanatory and learnable / "memorizable" / "internalizeable".


On many systems like Ubuntu you can use the l command. It by default shows all of the directories with a forward slash. It actually is an alias for ls -CF (as you can find out by running alias). These kind of aliases are usually defined in ~/.bashrc (in case you want to modify them or add additional ones).

  • Note that the resulting ls -F has been covered in existing answers. Other users may or may not have such an l alias...
    – Jeff Schaller
    Commented Aug 16, 2020 at 1:36
  • It is an alternative that could be present. Commented Aug 17, 2020 at 4:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .