Scripts bash que utilizo en Android con herramientas de utilidad para mí día a día.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Termux-shell/gnz_numAtxt-FR.sh

321 lines
6.6 KiB

#!/bin/bash
# Developed By Chetan Khatri
source fnc_gonzy.sh
function fnc_principal(){
fnc_gonzy_intro "Numero a texto (FR)" "Obtiene el texto (en frances) del número \ningresado, hasta 15 dígitos.\nAdaptado por Gonzy."
read -p "Número?: " number;
number=`echo $number | sed s/' '/''/g`
if [[ $? -gt 0 || -z $number ]] ; then
echo -e "\n *****Error : Número incorrecto \n"
exit 1
fi
if ! [[ "$number" =~ ^[0-9]+$ ]] ; then
exec >&2; echo -e "\n *****Error: No ea un entero. \n"; exit 1
fi
number=`echo "$number * 1" | bc 2> /dev/null`
GlobalLength=`expr length $number`
[ $GlobalLength -gt 15 ] && echo -e "\n *****Error : Longitud incorrecta ( $number ~~> $GlobalLength Digitos) \n" && exit 1
Convert
exit
}
function One()
{
local n=$1
if [ $n -eq "1" ] ; then
words=`echo -n "$words Un"`
elif [ $n -eq "2" ] ; then
words=`echo -n "$words Deux"`
elif [ $n -eq "3" ] ; then
words=`echo -n "$words Trois"`
elif [ $n -eq "4" ] ; then
words=`echo -n "$words Quatre"`
elif [ $n -eq "5" ] ; then
words=`echo -n "$words Cinq"`
elif [ $n -eq "6" ] ; then
words=`echo -n "$words Six"`
elif [ $n -eq "7" ] ; then
words=`echo -n "$words Sept"`
elif [ $n -eq "8" ] ; then
words=`echo -n "$words Huit"`
elif [ $n -eq "9" ] ; then
words=`echo -n "$words Neuf"`
elif [[ $GlobalLength -lt "2" && $n -eq "0" ]] ; then
words="Zéro"
fi
}
function Two()
{
local num=$1
local n=`echo ${num:0:1}`
local p=`echo ${num:1:1}`
if [ $n -eq "0" ] ; then
One $p
elif [[ $n -eq "1" && $p -eq "0" ]] ; then
words=`echo -n "$words Dix"`
elif [[ $n -eq "1" && $p -eq "1" ]] ; then
words=`echo -n "$words Onze"`
elif [[ $n -eq "1" && $p -eq "2" ]] ; then
words=`echo -n "$words Douze"`
elif [[ $n -eq "1" && $p -eq "3" ]] ; then
words=`echo -n "$words Treize"`
elif [[ $n -eq "1" && $p -eq "4" ]] ; then
words=`echo -n "$words Quatorze"`
elif [[ $n -eq "1" && $p -eq "5" ]] ; then
words=`echo -n "$words Quinze"`
elif [[ $n -eq "1" && $p -eq "6" ]] ; then
words=`echo -n "$words Seize"`
elif [[ $n -eq "1" && $p -eq "7" ]] ; then
words=`echo -n "$words Dix-sept"`
elif [[ $n -eq "1" && $p -eq "8" ]] ; then
words=`echo -n "$words Dix-huit"`
elif [[ $n -eq "1" && $p -eq "9" ]] ; then
words=`echo -n "$words Dix-neuf"`
elif [[ $n -eq "2" ]] ; then
words=`echo -n "$words Vingt"`
One $p
elif [[ $n -eq "3" ]] ; then
words=`echo -n "$words Trente"`
One $p
elif [[ $n -eq "4" ]] ; then
words=`echo -n "$words Quarante"`
One $p
elif [[ $n -eq "5" ]] ; then
words=`echo -n "$words Cinquante"`
One $p
elif [[ $n -eq "6" ]] ; then
words=`echo -n "$words Soixante"`
One $p
elif [[ $n -eq "7" ]] ; then
words=`echo -n "$words Soixante-dix"`
One $p
elif [[ $n -eq "8" ]] ; then
words=`echo -n "$words Quatre-vingts"`
One $p
elif [[ $n -eq "9" ]] ; then
words=`echo -n "$words Quatre-vingt-dix"`
One $p
fi
}
function Three()
{
local num=$1
local n=`echo ${num:0:1}`
local p=`echo ${num:1:2}`
if [ $n -gt 0 ] ; then
One $n
words=`echo "$words Cent"`
fi
Two $p
}
function Four()
{
local num=$1
local n=`echo ${num:0:1}`
local p=`echo ${num:1:3}`
if [ $n -gt 0 ] ; then
One $n
words=`echo "$words Mille,"`
fi
Three $p
}
function Five()
{
local num=$1
local n=`echo ${num:0:2}`
local p=`echo ${num:2:3}`
if [ $n -gt 0 ] ; then
Two $n
words=`echo "$words Thousand,"`
fi
Three $p
}
function Six()
{
local num=$1
local n=`echo ${num:0:3}`
local p=`echo ${num:3:5}`
if [ $n -gt 0 ] ; then
Three $n
words=`echo "$words Thousand,"`
fi
Three $p
}
function Seven()
{
local num=$1
local n=`echo ${num:0:1}`
local p=`echo ${num:1:6}`
if [ $n -gt 0 ] ; then
One $n
words=`echo "$words Million,"`
fi
Six $p
}
function Eight()
{
local num=$1
local n=`echo ${num:0:2}`
local p=`echo ${num:2:7}`
if [ $n -gt 0 ] ; then
Two $n
words=`echo "$words Million,"`
fi
Six $p
}
function Nine()
{
local num=$1
local n=`echo ${num:0:3}`
local p=`echo ${num:3:8}`
if [ $n -gt 0 ] ; then
Three $n
words=`echo "$words Million,"`
#
fi
Six $p
}
function Ten()
{
local num=$1
local n=`echo ${num:0:1}`
local p=`echo ${num:1:9}`
if [ $n -gt 0 ] ; then
One $n
words=`echo "$words Billion,"`
#
fi
Nine $p
}
function Eleven()
{
local num=$1
local n=`echo ${num:0:2}`
local p=`echo ${num:2:10}`
if [ $n -gt 0 ] ; then
Two $n
words=`echo "$words Billion,"`
fi
Nine $p
}
function Twelve()
{
local num=$1
local n=`echo ${num:0:3}`
local p=`echo ${num:3:11}`
if [ $n -gt 0 ] ; then
Three $n
words=`echo "$words Billion,"`
fi
Nine $p
}
function Thirteen()
{
local num=$1
local n=`echo ${num:0:1}`
local p=`echo ${num:1:12}`
if [ $n -gt 0 ] ; then
One $n
words=`echo "$words Trillion,"`
#
fi
Twelve $p
}
function Fourteen()
{
local num=$1
local n=`echo ${num:0:2}`
local p=`echo ${num:2:13}`
if [ $n -gt 0 ] ; then
Two $n
words=`echo "$words Trillion,"`
fi
Twelve $p
}
function Fifteen()
{
local num=$1
local n=`echo ${num:0:3}`
local p=`echo ${num:3:14}`
if [ $n -gt 0 ] ; then
Three $n
words=`echo "$words Trillion,"`
fi
Twelve $p
}
function Convert()
{
if [ $GlobalLength -eq "15" ] ; then
Fifteen $number
elif [ $GlobalLength -eq "14" ] ; then
Fourteen $number
elif [ $GlobalLength -eq "13" ] ; then
Thirteen $number
elif [ $GlobalLength -eq "12" ] ; then
Twelve $number
elif [ $GlobalLength -eq "11" ] ; then
Eleven $number
elif [ $GlobalLength -eq "10" ] ; then
Ten $number
elif [ $GlobalLength -eq "9" ] ; then
Nine $number
elif [ $GlobalLength -eq "8" ] ; then
Eight $number
elif [ $GlobalLength -eq "7" ] ; then
Seven $number
elif [ $GlobalLength -eq "6" ] ; then
Six $number
elif [ $GlobalLength -eq "5" ] ; then
Five $number
elif [ $GlobalLength -eq "4" ] ; then
Four $number
elif [ $GlobalLength -eq "3" ] ; then
Three $number
elif [ $GlobalLength -eq "2" ] ; then
Two $number
else
One $number
fi
fnc_msg_color 2 "Procesando."
sleep 1
echo -e "\n"
fnc_msg_color 1 "$words"
echo -e "\n"
}
fnc_principal