Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash single bracket and double square bracket

more likey [] is for math orerations 
[[ ]] for pattern matching, 


eg 1 ###########
eg: 
if [ $marks -ge 80 ];
then
	do something
fi


####################
eg2 :

#!/bin/bash
# your code goes here
echo "if double helix, type - dh " 
echo "single strand, type - ss"
read htype # this is catching input
echo Structure is $htype ;


if [[ $htype == dh ]];
then
     echo "##dublex#####"
else
    echo "#####single#####"
fi

but you can use both, use [[ ]] will be safe,

Note that [[ is actually a command/program that returns either 0 (true) or 1 (false). Any program that obeys the same logic (like all base utils, such as grep(1) or ping(1)) can be used as condition, see examples.

[[ -z STRING ]]	Empty string
[[ -n STRING ]]	Not empty string
[[ STRING == STRING ]]	Equal
[[ STRING != STRING ]]	Not Equal
[[ NUM -eq NUM ]]	Equal
[[ NUM -ne NUM ]]	Not equal
[[ NUM -lt NUM ]]	Less than
[[ NUM -le NUM ]]	Less than or equal
[[ NUM -gt NUM ]]	Greater than
[[ NUM -ge NUM ]]	Greater than or equal
[[ STRING =~ STRING ]]	Regexp
(( NUM < NUM ))	Numeric conditions
More conditions
[[ -o noclobber ]]	If OPTIONNAME is enabled
[[ ! EXPR ]]	Not
[[ X && Y ]]	And
[[ X || Y ]]	Or
Comment

PREVIOUS NEXT
Code Example
Shell :: git clone all repositories in organization 
Shell :: install sonic visualizer ubuntu 
Shell :: Git Branch usage order 
Shell :: how to install altair graphql on manjaro linux 
Shell :: kill traffic to port linux 
Shell :: what is linux 
Shell :: how to run a code in github 
Shell :: screen 
Shell :: CHROME_EXECUTABLE brave 
Shell :: powershell free disk space percentage all server liste 
Shell :: create file cmd windows 
Shell :: remove xcode archives 
Shell :: csv to column awk 
Shell :: nvcc issue in jetson nano 
Shell :: install wsl using this powershell script 
Shell :: how to create a patch file between 2 branches git 
Shell :: homestead.yaml adding provisions 
Shell :: unable to resolve dns when kubernetes is running on ubuntu 
Shell :: linux split with filename extension 
Shell :: install specific gitlab version on ubuntu 
Shell :: diskpart create partition 
Shell :: turn off wiregurad linux 
Shell :: Jupyter %%time 
Shell :: iptables linux 
Shell :: how to check my mint version 
Shell :: shell create random mac 
Shell :: how to install python package without admin rights 
Shell :: mongodb install issues 
Shell :: running wordpress locally with valet 
Shell :: git stash 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =