Sponsored Content
Full Discussion: Reverse of a string
Top Forums Shell Programming and Scripting Reverse of a string Post 302558502 by vgersh99 on Friday 23rd of September 2011 05:39:59 PM
Old 09-23-2011
Code:
echo 'abcdefghijk' | sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'

 

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

To reverse a string

Hi All, I would like to know , how to reverse a given string example : Hi how are you Required Output: you are how HiThanks (7 Replies)
Discussion started by: santhoshks
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
EVAL(3) 								 1								   EVAL(3)

eval - Evaluate a string as PHP code

SYNOPSIS
mixed eval (string $code) DESCRIPTION
Evaluates the given $code as PHP. Caution The eval(3) language construct is very dangerous because it allows execution of arbitrary PHP code. Its use thus is discouraged. If you have carefully verified that there is no other option than to use this construct, pay special attention not to pass any user provided data into it without properly validating it beforehand. PARAMETERS
o $code - Valid PHP code to be evaluated. The code mustn't be wrapped in opening and closing PHP tags, i.e. 'echo "Hi!";' must be passed instead of '<? echo "Hi!"; >'. It is still possible to leave and reenter PHP mode though using the appropriate PHP tags, e.g. 'echo "In PHP mode!"; ?>In HTML mode!<? echo "Back in PHP mode!";'. Apart from that the passed code must be valid PHP. This includes that all statements must be properly terminated using a semicolon. 'echo "Hi!"' for example will cause a parse error, whereas 'echo "Hi!";' will work. A return statement will immediately terminate the evaluation of the code. The code will be exe- cuted in the scope of the code calling eval(3). Thus any variables defined or changed in the eval(3) call will remain visible after it terminates. RETURN VALUES
eval(3) returns NULL unless return is called in the evaluated code, in which case the value passed to return is returned. If there is a parse error in the evaluated code, eval(3) returns FALSE and execution of the following code continues normally. It is not possible to catch a parse error in eval(3) using set_error_handler(3). EXAMPLES
Example #1 eval(3) example - simple text merge <?php $string = 'cup'; $name = 'coffee'; $str = 'This is a $string with my $name in it.'; echo $str. " "; eval("$str = "$str";"); echo $str. " "; ?> The above example will output: This is a $string with my $name in it. This is a cup with my coffee in it. NOTES
Note Because this is a language construct and not a function, it cannot be called using variable functions. Tip As with anything that outputs its result directly to the browser, the output-control functions can be used to capture the output of this function, and save it in a string (for example). Note In case of a fatal error in the evaluated code, the whole script exits. SEE ALSO
call_user_func(3). PHP Documentation Group EVAL(3)
All times are GMT -4. The time now is 09:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy