Bash – Override Builtin Commands using Functions

Bash – Override Commands

Bash – Override Commands : In this Bash Tutorial, we shall learn to override an inbuilt command using Bash Functions.

We may override commands in bash by creating a function with the same name as the command we would like to override. For example to overrideps  command, you have to create a function with nameps .

This could be helpful in  scenarios like you use a command with certain options, and you do not like to provide the whole command with options several times in your script. So you may override the command for command with options. Now let us learn how overriding commands could be done in Bash Shell Scripting.


Example – Bash – Override Command

In this example, we shall try overridingls  command forls -ltr .


Example – 2 – Bash – Override Command

In this example, we shall try overridingecho  command, and add time stamp in from of the argument toecho  command.


Conclusion :

In this Bash Scripting Tutorial, we have learnt to override commands with the help of Example Bash Scripts.