LIst of dirs without trailing slash "/"

Probably, your ls is aliased or defined as a function in your .bashrc or /etc/profile or elsewhere.

Try the full path to ls like

/bin/ls /var/lib/mysql/ 

Probably you've defined alias for ls which is doing that.

To run ls directly, run as \ls, e.g.

\ls /var/lib/mysql/

To see what's aliased to, run: type ls.

If so, remove alias by:

unalias ls

Otherwise, here is the workaround:

for dir in `ls -1 .`; do echo $dir; done

You should check your aliases for ls. For example,

$> alias ls
alias ls='ls --color=auto'

-F flag appends directory indicator, so you should remove it from your ls aliases if you don't need it.

About one item by line. ls have usable -1 flag, so it should works like

ls -1 /var/lib/mysql/
wachuwar_funkfow
wachuwar_prueba
webdeard_arde

Tags:

Linux

Bash

Awk

Sed