...

/

Difference Between Functions and Aliases

Difference Between Functions and Aliases

Learn cases when we should declare a function instead of an alias.

We'll cover the following...

If we want to shorten a long command, we use an alias.

When using the shell, we need a function in two cases only:

  1. We need a conditional statement, loop, or code block to perform our command.
  2. The input parameters are not at the end of the command.

The second case needs an example. Let’s shorten the find utility call. It should search for files in the specified directory. When we search them in the home directory, the find call looks like this:

find ~ -type f

Run the commands discussed in this lesson in the terminal below.

Access this course and 1400+ top-rated courses and projects.