We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
for(( i=0 ; i<${#line}; i++ ))
do
char="`${line:$`i:1}"
if [[ "$char" == ' ' ]]
then
if [[ $flag -eq 1 ]]
then
echo -n "$char"
flag=0
fi
else
echo -n "$char"
flag=1
fi
done
}
while read -r line
do
func "$line"
echo
done
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
'Tr' Command #3
You are viewing a single comment's thread. Return to all comments →
without tr command
func() { local flag=1 local line="$1"
}
while read -r line do func "$line" echo done