![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help needed for writing a script | sriram_1978 | Shell Programming and Scripting | 4 | 12-06-2007 04:10 AM |
| Writing the script | jess_t03 | Shell Programming and Scripting | 1 | 10-10-2007 06:17 AM |
| Help needed in writing awk script for xml source | naren_0101bits | Shell Programming and Scripting | 2 | 09-24-2007 02:07 AM |
| help writing script | dr46014 | Shell Programming and Scripting | 8 | 08-27-2007 05:08 AM |
| plz help in writing awk script | LAKSHMI NARAYAN | Shell Programming and Scripting | 3 | 07-14-2007 04:06 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
needed help in writing a script!
Hi all,
I needed help in writing a script for the following question.please help. Non-recursive shell script that accepts any number of arguments and prints them in the Reverse order. (For example, if the script is named rargs, then executing rargs A B C should produce C B A on the standard output). Thanks |
|
||||
|
For the Perl version, you can just say reverse @ARGV -- no need to code the loop by hand. Code:
#!/bin/sh exec perl -le '$, = " "; print reverse @ARGV' "$@" By manipulating $, you can avoid the explicit join. joeyg's orgy in temp files and Useless Use of Cat (no offense ...) can be simplified radically: Code:
echo "$@" | tr -s " \t" "\n" | tac | tr "\n" " " If your tr doesn't grok \t and \n you will have to use octal codes or literal tabs and newlines. |
![]() |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|