I want to add in my linux system a script call to the ls
command. This script should be executed each time the user execute the ls
command.
I tried 2 solutions but both are limited:
1) Using alias
alias ls="/root/myscript.sh; ls"
But this solution is limited because the user can call ls
via a variable in this way
var="ls"
$var
see this link for more details
2) Using function
I create a function with the name ls
:
ls() { /root/myscript.sh; /bin/ls $@ }
But this solution is limited because the user can call ls
in this way:
/bin/ls
Are there another solution?