Content added Content deleted
imported>mutante m (New page: <pre> #!/bin/bash # Convert string to ASCII code # mutante / s23.org declare -a INPUT echo "Enter characters seperated by space to be converted to ASCII code. " read -a INPUT char_count=${...) |
imported>mutante m (separated) |
||
Line 4: | Line 4: | ||
# mutante / s23.org |
# mutante / s23.org |
||
declare -a INPUT |
declare -a INPUT |
||
echo "Enter characters |
echo "Enter characters separated by space to be converted to ASCII code. " |
||
read -a INPUT |
read -a INPUT |
||
char_count=${#INPUT[*]} |
char_count=${#INPUT[*]} |
||
Line 17: | Line 17: | ||
</pre> |
</pre> |
||
Can you change this so that input does not have to be |
Can you change this so that input does '''not''' have to be separated by spaces anymore? |
||
[[Category:ASCII]] |
[[Category:ASCII]] |
Revision as of 20:45, 1 April 2008
#!/bin/bash # Convert string to ASCII code # mutante / s23.org declare -a INPUT echo "Enter characters separated by space to be converted to ASCII code. " read -a INPUT char_count=${#INPUT[*]} # echo $char_count i=0 while [ $i -lt $char_count ]; do ASCII=`perl -e 'print ord shift' ${INPUT[$i]}` CHAR=${INPUT[$i]} echo -e "$CHAR - $ASCII" i=$(($i+1)) done
Can you change this so that input does not have to be separated by spaces anymore?