I entered la accidentally instead of ls to view the contents of a directory and it produces exactly the same output as ls...
Why is this? Surely it doesn't make sense to have two commands that do the exact same thing.
I entered la accidentally instead of ls to view the contents of a directory and it produces exactly the same output as ls...
Why is this? Surely it doesn't make sense to have two commands that do the exact same thing.
la is an alias to ls -A defined in ~/.bashrc file in Ubuntu.
It only shows the same output if you have no hidden files or directories.
ls -A shows hidden files and directories.
la is defined as an alias in Ubuntus ~/.bashrc file together with a few others. la is simply an ls -A as you can see in the following snippet from the ~/.bashrc
# this alias is defined earlier to grant colored output
alias ls='ls --color=auto'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias li='ls -lF'
When in doubt, type la.
Bash output:
la is aliased to `ls -la'
Fish output:
la is a function with definition
function la --description 'List contents of directory, including hidden files in directory using long format'
ls -lah $argv
end
ls is a command, l and la are most likely aliases which make use of the command ls. If you run the command alias you can find all the aliases on your system.
$ alias | grep -E ' l=| la='
This will return all the aliases that match the pattern l=... or la=....
They do not produce the same output in all directories.
Create a dotfile with touch .whatever, then issue both la and ls.
la is an alias for ls -A, as stated by other answers. As such, it can't be used in shell scripts, while ls can.
Your computer has multiple aliased commands. A complete list can be obtained by executing alias. On my machine it prints this:
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
--color=auto means colour will be turned off when not printing directly to STDOUT.