I am trying to create an aliases in bash. What I want to do is map ls -la
to ls -la | more
In my .bashrc file this is what I attempted:
alias 'ls -la'='ls -la | more'
However it does not work because (I assume) it has spaces in the alias name. Is there a work around for this?
Best Answer
The Bash documentation states "For almost every purpose, shell functions are preferred over aliases." Here is a shell function that replaces
ls
and causes output to be piped tomore
if the argument consists of (only)-la
.As a one-liner:
Automatically pipe output: