command line arguments

This is just to demonstrate the command line arguments in a shell script

#!/bin/bash

# Script that demonstrate, command line arguments

echo "Total number of command line argument are: $#"

echo "script name is: $0"

echo "$1 is first argument"

echo "$2 is second argument"

echo "All of them are :- $* or $@"

# sh filename.sh 1 2 3 4 5 (arguments)

$* - This denotes all the parameters passed to the script at the time of its execution

$@ - denotes all the parameters passed to the script at the time of its execution

$0 - Name of the shell script being executed

$$ - Pid of current process

$# - Number of arguments specified in the command line

$? - Exit status of the last command

To see the process Id of the current shell
# echo $$ 
 
Exit status of a command 
# echo $?

The above symbols are known as positional parameters.

Terima kasih telah membaca artikel tentang command line arguments di blog Tutorial Opensource and Linux jika anda ingin menyebar luaskan artikel ini di mohon untuk mencantumkan link sebagai Sumbernya, dan bila artikel ini bermanfaat silakan bookmark halaman ini di web browser anda, dengan cara menekan Ctrl + D pada tombol keyboard anda.

Artikel terbaru :