Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash parameter count

# use $#

# say if you are expecting exactly 2 parameters
# -ne is bash's way of saying not equal
if [[ "$#" -ne 2 ]]; then
	echo "this script needs exactly 2 parameters"
    exit 1
 fi
Comment

bash count number of arguments

The number of arguments is $#
Comment

PREVIOUS NEXT
Code Example
Shell :: install zsh 
Shell :: linux remove last line from file 
Shell :: How to install tensorflow-gpu in ubuntu and Linux 
Shell :: bootstrap 5 react npm 
Shell :: how to commit to github from terminal 
Shell :: Setfacl 
Shell :: Undo commit and keep all files staged 
Shell :: Get all changes of the main branch locally 
Shell :: apt remove 
Shell :: how to install ansible in centos 
Shell :: how to check version of web3 
Shell :: trusted installer owner 
Shell :: aws eks update-kubeconfig 
Shell :: javascript bootstrap in reactJs 
Shell :: install nodejs with pacman 
Shell :: string manipulation in shell 
Shell :: centos copy files ssh 
Shell :: ubuntu shell touch multiple files 
Shell :: connecting sublime to bash command line 
Shell :: change commit author after push 
Shell :: how to trim log file linux 
Shell :: docker force a rebuild 
Shell :: reduce file size of mp4 using ffmpeg 
Shell :: keep the container running and not exit directly 
Shell :: unzip command in linux 
Shell :: error: Not a valid ref: refs/remotes/origin/master 
Shell :: permission exec linux 
Shell :: install imagick 
Shell :: install psycopg2 
Shell :: untar gz file ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =