Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,14 @@
s1="rosetta code phrase reversal"
echo "Original string ----------------------> "$s1
echo -n "1.) Reverse the string ---------------> "
echo $s1|rev
echo -n "2.) Reverse characters of each word --> "
echo $s1|tr " " "\n"|rev|tr "\n" " ";echo
echo -n "3.) Reverse word order ---------------> "
word_num=$(echo $s1|wc -w)
while [ $word_num != 0 ];do
echo -n $(echo $s1|cut -d " " -f $word_num);echo -n " "
word_num=$(expr $word_num - 1);done;echo

View file

@ -0,0 +1,26 @@
s1="rosetta code phrase reversal"
echo "Original string --> "$s1
echo -n "1.) Reverse the string --> "
length=$(echo $s1|wc -c)
while [ $length != 0 ];do
echo $s1|cut -c$length|tr -d "\n"
length=$(expr $length - 1)
done;echo
echo -n "2.) Reverse characters of each word --> "
word_quantity=$(echo $s1|wc -w)
word_quantity=$(expr $word_quantity + 1)
word_num=1
while [ $word_num != $word_quantity ];do
length=$(echo $s1|cut -d " " -f $word_num|wc -c)
while [ $length != 0 ];do
echo $s1|cut -d " " -f $word_num|cut -c$length|tr -d "\n"
length=$(expr $length - 1);done;echo -n " "
word_num=$(expr $word_num + 1);done;echo
echo -n "3.) Reverse word order --> "
word_num=$(echo $s1|wc -w)
while [ $word_num != 0 ];do
echo -n $(echo $s1|cut -d " " -f $word_num);echo -n " "
word_num=$(expr $word_num - 1);done;echo