Receive all updates via Facebook. Just Click the Like Button Below

Command Line Arguments in Shell Scripts

The command line arguments are important in shell scripts.
This help users to pass values directly to the script using command line.

Command Line Arguments in Linux Shell Scripting

Reading command line arguments

Lets try it with an example script:

# Script that demos, command line args
echo "Total number of command line argument are $#"
echo "$0 is script name"
echo "$1 is first argument"
echo "$2 is second argument"
echo "All of them are :- $* (or) $@"

Running the script:
chmod 755
./ 1 2 3 4 last
Total number of command line argument are 5
./ is script name
1 is first argument
2 is second argument
All of them are :- 1 2 3 4 last (or) 1 2 3 4 last

$* (or) $@ can be used to print or read all the command line arguments.
$1 is the first argument, $2 the second, $3 the third and so on.

Related posts:

Advertise here

picture picture

Follow us


- Tech-Tutorials

Like us

About Techcuriosity

I am Telson, the webmaster of and through this site, I share my knowledge and curiosities in the Tech World.

What We Offer

  • What is ..?
  • How to ..?
  • Difference between ..?
  • How .. works?
  • Get in Touch
    UAE : +971-55-83-566-04
    India : +91 - 9526244217

    picture picture

    Our Partners

  • Website Design Dubai
  • SEO Link Exchange
  • picture