Structure Query Language, C programming, Java, Servlet, Jsp, Unix

Wednesday, 22 February 2012

Fetch the data from a file and display data into another file in reverse order.


echo "Enter filename"
read filename
if [ ! -f $filename ];then
echo "file not exist"
exit 1
fi
str=`cat $filename`
len=`echo $str|wc -c`
i=$len
while [ $i -ge 1 ]
do
temp=$temp`echo $str|cut -c $i`
i=`expr $i - 1`
done
echo $temp>newfile.txt

No comments:

Post a Comment