Content added Content deleted
imported>mutante m (separated) |
imported>mutante mNo edit summary |
||
Line 7:
read -a INPUT
char_count=${#INPUT[*]}
i=0
while [ $i -lt $char_count ]; do
Line 21 ⟶ 20:
[[Category:ASCII]]
[[Category:Scripts]]
[[Category:Bash]]
|
Revision as of 20:49, 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[*]} 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?