HI
I have file A.txt
_1A
_2A
_3A
_4A
I want define all as different variable.
$1A=_1A
$2B=_2A
$3C=_3A
$4D=_4A
Now i can use any variable in my script.
HI
I have file A.txt
_1A
_2A
_3A
_4A
I want define all as different variable.
$1A=_1A
$2B=_2A
$3C=_3A
$4D=_4A
Now i can use any variable in my script.
Array is the best option here.
Here is an example using Indexed Array:
#/bin/ksh
typeset -a ARR
c=0
while read line
do
(( ++c ))
ARR[$c]="$line"
done < A.txt
for k in ${!ARR[@]}
do
printf "%s\n" "${ARR[$k]}"
done
thanks men
Is there any simple code because i have only 4 lines and its fixed.
You could simplify it slightly.
#/bin/ksh
while read LINE; do
ARR[${#ARR[@]}]="$LINE"
done < A.txt
printf "%s\n" "${ARR[@]}"