[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


how do u reverse a string using UNIX commands

<< Back to: Unix - Frequently Asked Questions (1/7) [Frequent posting]

Question by shilps
Submitted on 5/13/2004
Related FAQ: Unix - Frequently Asked Questions (1/7) [Frequent posting]
Rating: Rate this question: Vote
how do u reverse a string using UNIX commands



Answer by rupert
Submitted on 5/19/2004
Rating:  Rate this answer: Vote
hold a mirror to the screen

 

Answer by saurabh
Submitted on 6/15/2004
Rating:  Rate this answer: Vote
stand wid your legs up and head down in front of the screen

 

Answer by aminorex
Submitted on 4/18/2005
Rating: Not yet rated Rate this answer: Vote
The BSD 'rev' command does this.  It is available on my Linux box thanks to the package "util-linux".

 

Answer by dwatson
Submitted on 6/26/2005
Rating: Not yet rated Rate this answer: Vote
unix:
echo "hello world" |sed 's/./&\n/g' |tac |tr -d '\n'

linux:
echo "hello world" |rev
dlrow olleh

 

Answer by dwatson
Submitted on 6/27/2005
Rating: Not yet rated Rate this answer: Vote
in unix:
echo "hello world" |sed 's/./&\n/g' |tac |tr -d '\n'

in linux:
echo "hello world" |rev
dlrow olleh

 

Answer by superHelpfulguy
Submitted on 8/1/2005
Rating: Not yet rated Rate this answer: Vote
thanks for the super-helpful answers!!

 

Answer by Robert
Submitted on 7/24/2006
Rating: Not yet rated Rate this answer: Vote
Hi,
I dont know the answer i want to know many things from the Unix experts.

Thanks®ards
Robert.T

 

Answer by pavan
Submitted on 10/24/2006
Rating: Not yet rated Rate this answer: Vote
use "rev" command to reverse a string. or we can write our own code as follows:

clear
echo "Enter the string to be reversed: "
read str
len=`echo $str | wc -c`
len=`expr $len - 1`
rev=""
while test $len -gt 0
do
rev1=`echo $str | cut -c$len`
rev=$rev$rev1
len=`expr $len - 1`
done
echo $rev

 

Answer by David
Submitted on 1/30/2007
Rating: Not yet rated Rate this answer: Vote
Use awk: e.g., joe maxage=0 is string.  Run: echo "joe maxage=0" | awk '{ print $2" "$1 }'

 

Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: Unix - Frequently Asked Questions (1/7) [Frequent posting]


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.