用shell将一个字符串作为参数传递给程序,程序实现倒序输出。如字符串...
发布网友
发布时间:2024-05-12 04:08
我来回答
共2个回答
热心网友
时间:2024-06-11 01:54
#!/usr/bin/bash
string=$1
length=$((${#string}-1))
reversed=${string:$length:1}
length=$(($length-1))
while [ $length -ne -1 ]
do
reversed=${reversed}${string:$length:1}
length=$(($length-1))
done
echo $reversed
热心网友
时间:2024-06-11 02:00
#!/bin/bash
read -p "please enter a word: " word
eval "echo $word | perl -ple '\$_ = reverse \$_;'"