Category Archives: Linux Shell Scripting

Sourcing files in Linux Shell Scripting

“source” command is used to source any valid shell script file. Here is the syntax of source command.

source <script-file-name>

Main purpose of source command is that we can use functions or commands defined in another file in any other script or from in shell prompt.

Note that if you want to execute any script file, you should have a execute permission on that file. But When you use “source” command, you do not need to have a execute permission on that file.

Suppose you have simple script file – “s1.sh” with below contents

ls

Now to execute “s1.sh”, you can use below command.

$ source s1.sh