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 :

  • How To Install Cinnamon In Ubuntu 14.04
  • How To Install Mate Desktop In Ubuntu 14.04
  • Creating the first Windows Server 2003 Domain Controller in a domain
  • How To Install Ubuntu 13.10 Server
  • How to Install Nuvola Player in Ubuntu
  • How to establish Emerald in Ubuntu 13.10 & Linux Mint 16
  • How to Restoring iptables Automatically On Boot on Debian and Ubuntu
  • How to Compile FFMPEG with H.264 and LAME in Ubuntu And Debian
  • How to Install Linux on a Playstation 2
  • apt-fast: Improve apt-get Download Speed
  • Artikel terkait :