initial commit
This commit is contained in:
14
bash/reverse-string/reverse_string.sh
Executable file
14
bash/reverse-string/reverse_string.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
[[ $# != 1 ]] && echo "usage: $0 string" && exit 1
|
||||
|
||||
|
||||
str=$1
|
||||
len=${#str}
|
||||
rev=""
|
||||
|
||||
for (( i=0; i<len; ++i ))
|
||||
do
|
||||
rev="${str:i:1}$rev"
|
||||
done
|
||||
echo "$rev"
|
||||
Reference in New Issue
Block a user