alhassani54
Programmer
The script below will take the value from tarsds and write it to a file by converting the list from one row list contains many cloumns to many rows contain one column.
'tarsds' could be = null, could be = one value or could be = more than one value.
Is there a way to simplify the script?
Thank you
tarsds="tarsds200.Z"
cnt=1
otarsds=""
while [[ $cnt != 0 ]]
do
ntarsds=`echo $tarsds | cut -d" " -f$cnt-$cnt`
if [[ $ntarsds = $otarsds ]]; then ntarsds=""; fi
if [[ $ntarsds != "" ]]; then
((cnt=cnt+1))
nntarsds=`echo $ntarsds | cut -d"." -f1-1 >>ntarsds1`
otarsds=$ntarsds
else
cnt=0
fi
done
# cat ntarsds1
Tarsds200
or
tarsds="tarsds200.Z tarsds100.Z tarsds400.Z"
cnt=1
otarsds=""
while [[ $cnt != 0 ]]
do
ntarsds=`echo $tarsds | cut -d" " -f$cnt-$cnt`
if [[ $ntarsds = $otarsds ]]; then ntarsds=""; fi
if [[ $ntarsds != "" ]]; then
((cnt=cnt+1))
nntarsds=`echo $ntarsds | cut -d"." -f1-1 >>ntarsds1`
otarsds=$ntarsds
else
cnt=0
fi
done
# cat ntarsds1
tarsds200
tarsds100
tarsds400
'tarsds' could be = null, could be = one value or could be = more than one value.
Is there a way to simplify the script?
Thank you
tarsds="tarsds200.Z"
cnt=1
otarsds=""
while [[ $cnt != 0 ]]
do
ntarsds=`echo $tarsds | cut -d" " -f$cnt-$cnt`
if [[ $ntarsds = $otarsds ]]; then ntarsds=""; fi
if [[ $ntarsds != "" ]]; then
((cnt=cnt+1))
nntarsds=`echo $ntarsds | cut -d"." -f1-1 >>ntarsds1`
otarsds=$ntarsds
else
cnt=0
fi
done
# cat ntarsds1
Tarsds200
or
tarsds="tarsds200.Z tarsds100.Z tarsds400.Z"
cnt=1
otarsds=""
while [[ $cnt != 0 ]]
do
ntarsds=`echo $tarsds | cut -d" " -f$cnt-$cnt`
if [[ $ntarsds = $otarsds ]]; then ntarsds=""; fi
if [[ $ntarsds != "" ]]; then
((cnt=cnt+1))
nntarsds=`echo $ntarsds | cut -d"." -f1-1 >>ntarsds1`
otarsds=$ntarsds
else
cnt=0
fi
done
# cat ntarsds1
tarsds200
tarsds100
tarsds400