Skip to content
Nishant Munjal
  • About
  • NMRIL Labs
  • Courses
  • ResearchExpand
    • Research Publications
    • Books
    • Patents
    • Ph.D. Supervised
  • Workshop/Conferences
  • ToolsExpand
    • Creative Image Converter
    • Creative QRCode Generator
    • Creative QR Code Generator Tool
    • EMI Calculator
    • SIP Calculator
  • Blog
  • Resume
One Page CV
Nishant Munjal

Unix Special Variables

Special Variables

Sr. No.Variable & Description
1.$0 – The filename of the current script.
2.$n – These variables correspond to the arguments with which a script was invoked. Here n is a positive decimal number corresponding to the position of an argument (the first argument is $1, the second argument is $2, and so on).
3.$# – The number of arguments supplied to a script.
4.$* – All the arguments are double quoted. If a script receives two arguments, $* is equivalent to $1 $2. It takes input as string. For difference, run the script /unix-variable-and-difference/
5.$@ – All the arguments are individually double quoted. If a script receives two arguments, $@ is equivalent to $1 $2.  It takes input as array.
6.$? – The exit status of the last command executed. Output ‘0’ if all successful ‘1’ if unsuccessful.
7.$$ – The process number of the current shell. For shell scripts, this is the process ID under which they are executing.
8.$! – The process number of the last background command.
9.$1-$9 – Command Line Arguments

Example

File Name: specialchar.sh

#!/bin/sh

echo “File Name: $0”
echo “First Parameter : $1”
echo “Second Parameter : $2”
echo “Quoted Values: $@”
echo “Quoted Values: $*”
echo “Total Number of Parameters : $#”

Command to Run: ./specialchar.sh Nishant Munjal

Scripts

Nishant Munjal

Coding Humanity’s Future </>


Facebook Twitter Linkedin YouTube Github Email

Tools

  • SIP Calculator
  • EMI Calculator
  • Creative QR Code
  • Image Converter

Resources

  • Blog
  • Contact
  • Refund and Returns

Legal

  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

© 2026 Nishant Munjal - All Rights Reserved

  • About
  • NMRIL Labs
  • Courses
  • Research
    • Research Publications
    • Books
    • Patents
    • Ph.D. Supervised
  • Workshop/Conferences
  • Tools
    • Creative Image Converter
    • Creative QRCode Generator
    • Creative QR Code Generator Tool
    • EMI Calculator
    • SIP Calculator
  • Blog
  • Resume
Download CV
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.