Read through the script below. This better explains the usage
#!/bin/bash
# This script is to explain the special char #
# Sijo George sijo.george@gmail.com
#------------------START------------------------#
#This is a comment
echo "This is #not a comment"
echo 'This also # is not a comment'
echo But ...This is a #comment
echo However This \# is not a comment
echo "Parameter sub is not a comment"
echo ${PATH}
echo ${PATH#*:};# Cuts of the shortest string of pattern after the # from the front
echo ${PATH##*:};# Cuts of the longest string of pattern after the # from the front
echo "Base conversion is not a comment "
echo $((2#1010)) # Convers binary 1010 to decimal
echo $((16#ABCD)) # Converts hex ABCD to decimal
string="this is a string"
echo ${#string} # Gives the number of characters in the string
array=(1 test a 10)
echo ${#array} # Gives the length of first element of the array
echo ${#array[*]} # Gives the number of elements in the array
echo ${#array[@]} # Gives the number of elements in the array
echo ${#} # Gives the number of command line parameters.
echo ${#*} #Gives the number of command line parameters.
echo ${#@} #Gives the number of command line parameters.
No comments:
Post a Comment