Sponsored Content
Full Discussion: To reverse a string
Top Forums Shell Programming and Scripting To reverse a string Post 302715593 by elixir_sinari on Monday 15th of October 2012 06:19:30 AM
Old 10-15-2012
This thread might help you:
https://www.unix.com/shell-programmin...sh-cshell.html
The last post in this thread should be interesting.

And, for this particular example, try:
Code:
perl -e '$str="Hi how are you";
while($str =~ /.*(\b\w+\b)/) { print $1," ";$str =~ s/(.*)(\b\w+\b)/\1/} print "\n"'

producing
Code:
you are how Hi


Last edited by elixir_sinari; 10-15-2012 at 07:32 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

string in reverse

Can we print any string in reverse order? For example: oracle 16294 1 0 Aug 11 ? 0:00 ora_reco_crepd oracle 16276 1 0 Aug 11 ? 0:19 ora_dbw0_crepd I need second last column from this output. (0:00 & 0:19). I can use awk print $2 after reversing the string. ... (4 Replies)
Discussion started by: malaymaru
4 Replies

2. Shell Programming and Scripting

reverse string manipulation

How to get the reverse parsing work. I have a strings like aqw-wef-324-err.log wefd-324r-err.log efrt-4rfr.log . . i want to have string upto last hypen. aqw-wef-324 wefd-324r ... (1 Reply)
Discussion started by: senthilk615
1 Replies

3. Filesystems, Disks and Memory

shell program to reverse the string

pls help me in getting that program (1 Reply)
Discussion started by: saikiran
1 Replies

4. Shell Programming and Scripting

PerL Reverse the string.

Hi, I am very new to perl. My question: How i can reverse the given string using substr function but without using reverse function in perl? Anybody please help. thanks, -Lalit (3 Replies)
Discussion started by: email-lalit
3 Replies

5. Shell Programming and Scripting

reverse a string based on else

I have a file like this: Dog Cat One ABCDEFGHIJ house Dog Cat Two ABCDEFGHIJ house Cat Cat One ABCDEFGHIJ house Cat Cat Two ABCDEFGHIJ house I want to look at $3 and if it says "Two" print out the line except reverse $4. Dog Cat One ABCDEFGHIJ house Dog Cat Two JIHGFEDCBA house ... (3 Replies)
Discussion started by: dcfargo
3 Replies

6. Programming

String reverse

Hi all, I jus wanna print string b after reversing it. but the out put is blank. My code snippet is below. :wall: int main() { char * a, * b; b = new char; a = new char; int len, le; le = 0; cout<< " enter your string \n"; cin>> a; len = strlen(a); for(int i =... (8 Replies)
Discussion started by: vineetjoshi
8 Replies

7. Shell Programming and Scripting

reverse string matching

Guys, I am trying to find a way to achieve this. I need to print /usr/local/apche/htdocs only from the string /usr/local/apache/htdocs/file.php using the regex. The below did not work. I know a solution with normal cut, I need a way to do this with the awk regex. awk '/+file.php/' (6 Replies)
Discussion started by: anilcliff
6 Replies

8. Shell Programming and Scripting

Reverse of a string

Hi All, I have a String str="Manish". I would like to reverse it. I know the option to do this in bash is: echo "Manish" | rev but I have seen an alternate solution somewhere, which states that: str="Manish" echo $str | awk '{ for(i=length($0);i>=1;i--) printf("%s",substr($0,i,1));... (7 Replies)
Discussion started by: manishdivs
7 Replies

9. Shell Programming and Scripting

awk reverse string

Hello, Can anyone explain for me in this script to reverse the string? 1) the "x=x" part, how it works? $ echo welcome | awk '{ for(i=length;i!=0;i--)x=x substr($0,i,1);}END{print x}' $ emoclew2) x seems to be an array at the END, but can it automatically print the whole array in awk? Thanks... (8 Replies)
Discussion started by: yifangt
8 Replies

10. UNIX for Dummies Questions & Answers

How to cut part of a string in reverse?

Hi, how to cut part of a string sing delimiter in reverse input file 1,2,st-pa-tr-01,2,3,4, 2,3,ff-ht-05,6,7,8 how can i obtain strings till st-pa-tr ff-ht i.e cutting the last part og string -01 and -05 Thanks & Regards Nivi edit by bakunin: changed thread title (typo) (3 Replies)
Discussion started by: nivI
3 Replies
RE-PCR(1)						      General Commands Manual							 RE-PCR(1)

NAME
re-PCR -- Find sequence tagged sites (STS) in DNA sequences SYNOPSIS
re-PCR [-hV] -p hash-file [-g gaps] [-n mism] [-lq] [primer ...] re-PCR [-hV] -P hash-file [-g gaps] [-n mism] [-l] [-m margin] [-O+|-] [-C batchcnt] [-o outfile] [-r+|-] [primers-file ...] re-PCR [-hV] -s hash-file [-g gaps] [-n mism] [-lq] [-m margin] [-o outfile] [-r+|-] [left right lo[-hi] [...]] re-PCR [-hV] -S hash-file [-g gaps] [-n mism] [-lq] [-m margin] [-O+|-] [-C batchcnt] [-o outfile] [-r+|-] [stsfile ...] DESCRIPTION
Implements reverse searching (called Reverse e-PCR) to make it feasible to search the human genome sequence and other large genomes by per- forming STS and primer searches. OPTIONS
-p=hash-file Perform primer lookup using hash-file -P=hash-file Perform primer lookup using hash-file -s=hash-file Perform STS lookup using hash-file -S=hash-file Perform STS lookup using hash-file -n=mism Set max allowed mismatches per primer for lookup -g=gaps Set max allowed indels per primer for lookup -m=margin Set variability for STS size for lookup -l Use presize alignments (only if gaps>0) -G Print alignments in comments -d=min-max Set default STS size -r=+|- Enable/disable reverse STS lookup -O=+|- Enable/disable syscall optimisation -C=batchcnt Set number of STSes per batch -o=outfile Set output file name -q Quiet (no progress indicator) EXAMPLE
famap -tN -b genome.famap org/chr_*.fa fahash -b genome.hash -w 12 -f3 ${PWD}/genome.famap re-PCR -s genome.hash -n1 -g1 ACTATTGATGATGA AGGTAGATGTTTTT 120-200 See famap(1) and fahash(1) SEE ALSO
/usr/share/doc/ncbi-epcr/README.txt bioperl(1), e-pcr(1), famap(1) and fahash(1) AUTHORS
This manual page was written by Andreas Tille <tille@debian.org> for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. April 2008 RE-PCR(1)
All times are GMT -4. The time now is 06:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy