variables
svar=123
echo "the value is ${svar}"
the value is 123
echo "the value is $svar"
the value is 123
finding length of string:
echo "the value is ${#svar}"
the value is 3
------------------------
no1=4
no2=5
let res=no1+no2
echo $res
9
g=no1+no2
echo $g
no1+no2
let res2=no1+no2
echo $res2
9
-----------------------
You can redirect stderr exclusively to a file and stdout to another file as follows:
$ cmd 2>stderr.txt 1>stdout.txt
------------------
Creating custom file descriptors, as 0,1,2 stdin,out,err
echo this is a test line > input
exec 3<input
cat <&3
this is a test line
----------------------------
arrays
f[0]="abc"
f[1]="def"
echo ${f[0]}
abc
Show full arrays elements
echo ${f[*]}
abc def
show arrays length:
echo ${f[*]}
abc def
2
-----
Show declared variables
declare -p | tail -7
declare -a f='([0]="abc" [1]="def")'
declare -- g="no1+no2"
declare -- no1="5"
declare -- no2="5"
declare -- res="9"
declare -- res2="9"
declare -- svar="123"
echo "the value is ${svar}"
the value is 123
echo "the value is $svar"
the value is 123
finding length of string:
echo "the value is ${#svar}"
the value is 3
------------------------
no1=4
no2=5
let res=no1+no2
echo $res
9
g=no1+no2
echo $g
no1+no2
let res2=no1+no2
echo $res2
9
-----------------------
You can redirect stderr exclusively to a file and stdout to another file as follows:
$ cmd 2>stderr.txt 1>stdout.txt
------------------
Creating custom file descriptors, as 0,1,2 stdin,out,err
echo this is a test line > input
exec 3<input
cat <&3
this is a test line
----------------------------
arrays
f[0]="abc"
f[1]="def"
echo ${f[0]}
abc
Show full arrays elements
echo ${f[*]}
abc def
show arrays length:
echo ${f[*]}
abc def
2
-----
Show declared variables
declare -p | tail -7
declare -a f='([0]="abc" [1]="def")'
declare -- g="no1+no2"
declare -- no1="5"
declare -- no2="5"
declare -- res="9"
declare -- res2="9"
declare -- svar="123"
Comments
Post a Comment