Shell Script To Find Arguments Length or Number Arguments

In Linux there is a variable available to holds the length of arguments.

The variable is $#.

Usage:

Write a script t.sh as following

echo $#

Now save and exit form script.

To execute the Script run the following code on your terminal.

$ sh t.sh 1 1 1

The output after executing above command is 3, since the number of arguments we passed to the script t.sh are 3.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s