Let's say I am in console in a subfolder, that is a child (or grandchild, etc.) of a symlinked (soft) folder.

From the subfolder, if I do ls -la nothing indicates all the files are inside a symlinked folder.

How could I know that? Currently, I have to go to the parent folder to know that.

But it means finding by test error, testing all the hierarchy of folders until arriving to the parent (linked).


I added $(pwd -P) to my bash prompt; this gives the real folder name instead of the symlinked one. There's no command switch with ls that I know of that will give you what you want. But at least changing the prompt will give you the exact location you're currently in.


Based on @ajgringo619

This solves it:

# includes complete left path
alias ls2l='if [[ $(diff <(ls "$PWD" | sed "s|.*|$(ls -d "$PWD/")&|g") <(ls -d "$(pwd -P)/"*) | wc -l) == "0" ]]; then ls -l; else paste -d " -> " <(ls "$PWD" | sed "s|.*|$(ls -d "$PWD/")&|g") /dev/null /dev/null /dev/null <(ls -d "$(pwd -P)/"*); fi'

# or 

alias  ls2='if [[ $(diff <(ls "$PWD" | sed "s|.*|$(ls -d "$PWD/")&|g") <(ls -d "$(pwd -P)/"*) | wc -l) == "0" ]]; then ls -l; else paste -d " -> " <(ls "$PWD") /dev/null /dev/null /dev/null <(ls -d "$(pwd -P)/"*); fi'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.