The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
adding order number in the output file happyv Shell Programming and Scripting 20 03-12-2007 10:12 PM
reversing order of lines in a file gfhgfnhhn Shell Programming and Scripting 11 03-04-2007 11:14 PM
HELP !! Builting string in incremental order u263066 Shell Programming and Scripting 6 08-14-2006 02:50 AM
Reversing and trim a String through SHELL script DeepakXavier Shell Programming and Scripting 5 09-28-2005 06:25 AM
Reversing file order using SED MBGPS Shell Programming and Scripting 2 09-30-2002 06:43 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-18-2005
ccp ccp is offline
Registered User
 

Join Date: Nov 2005
Posts: 14
output string in reversing order

If I have string { I_love_shell_scripts}
anyone knows how to have output {stpircs_llehs_evol_I}
by using shell and perl ?I know in perl, there is reverse() funcation, but
can it be done by not using reverse()?
Reply With Quote
Forum Sponsor
  #2  
Old 11-18-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
Looks like homework. Is it? May be you should solve this one on your own.
Reply With Quote
  #3  
Old 11-19-2005
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
this had been already posted

you should have tried with the search option

here is the link

could u please make a try!!!

reversing a string
Reply With Quote
  #4  
Old 11-19-2005
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,477
Quote:
Originally Posted by ccp
I know in perl, there is reverse() funcation, but
can it be done by not using reverse()?
Of course yes. This is simple enough. Are you ready to try it on your own?

My implementation is a subroutine that contains only 3 statements using a recursive scheme. This is one way.

Another way: you can always find the length() of the string, so you know the largest character position is 1 less than that value, then write a loop to read each character backwards with substr().
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0