O'Reilly logo

Linux Shell Scripting Essentials by Sinny Kumari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Passing command line parameters to script

So far, we have seen the usage of the commands such as grep, head, ls, cat, and many more. These commands also support passing arguments to a command via a command line. Some of command line arguments are input files, output files, and options. Arguments are provided as per output needs. For example, ls -l filename is executed to get a long listing output, while ls -R filename is used to display recursively the contents of a directory.

Shell script also supports providing command line arguments that we can process further by a shell script.

The command line arguments can be given as follows:

<script_file> arg1 arg2 arg3 … argN

Here, script_file is a shell script file to be executed, and arg1, arg2, arg3 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required