Overview - Function arguments ($1, $2 inside function)
What is it?
In bash scripting, functions can receive inputs called arguments. Inside a function, these inputs are accessed using special variables like $1, $2, and so on, where $1 is the first argument, $2 the second, etc. This lets the function work with different data each time it runs. Arguments make functions flexible and reusable.
Why it matters
Without function arguments, every function would do the exact same thing every time, making scripts repetitive and hard to maintain. Arguments let you pass different information to functions, so you can write one function that handles many cases. This saves time and reduces errors in scripts.
Where it fits
Before learning function arguments, you should understand how to write basic bash functions and how to run scripts. After this, you can learn about special variables like $@ and $#, and how to handle optional or named arguments for more advanced scripting.