How to Reverse a sentence in linux ? (bash/cshell)
hey all,
If I have the given sentence.
How could I reverse it to be :
I am NOT talking about reversing words or characters by using rev. I am talking about reversing the whole sentence(placement of words in the given sentence).
Neither one of these is really perfect, as it leaves the period placement wonky. You could fix it, but this seems like kind of a silly exercise to put that much effort into.
I am NOT talking about reversing words or characters by using rev. I am talking about reversing the whole sentence(placement of words in the given sentence).
thank you.
You don't define what you mean by "word", but since you want.boboinstead ofbobo.it is clear that you aren't using the same definition used by documentation of the shell.
Most of the responses on this thread so far use the definition of word normally used by the shell and assume that the separator to be output between words is always a space. Some of them even terminate the output line(s) with a space instead of a <newline> character.
You don't say what is supposed to happen to the separators between words (except for one example of a period). You also don't say whether your input is limited to a single line (as in your example) or whether each line is to be reversed in multi-line input. The following awk script will process all lines in a text file (even if the input is an empty file). It assumes that the definition of word is a contiguous string of alphanumeric characters. And it treats any contiguous string of non-alphanumeric characters as a word separator and preserves them in the output in the given order.
This script won't create any security holes and will work with any mostly POSIX-conforming shell (at least bash, sh, and ksh); it won't work with csh or tcsh:
The output produced with several test cases is shown below. (You can remove the printf that displays the input lines if you want to, but it helps here so you can see the transformtions it performs.)
Hope this helps...
hi guys,
10 years a go I wrote an script in bash programming and I compiled (obfuscate) it, but after 10 years I need to change some lines and remove some lines, but i do not remember what I've done.
does anyone has any idea about decompile (deobfuscation) it?
here is some line of my code (u... (3 Replies)
Hi,
In the archives I found this:
And this works fine.
$if mode=vi
"\C-0-": digit-argument
TAB: menu-complete
"\e
But what I want is to reverse this. So I want that tab does reverse menu completion and shift tab does normal menu completion.
Can anyone help me with this? Thanks (0 Replies)
The following thread is closed: 133552-howto-linux-multihomed-dns-client (Sorry I am not allowed to post URLs)
Therefore I write this append in an own thread.
The HOWTO in the referenced thread helped me a lot and I only want to append how to make reverse lookup working for a local zone:
... (0 Replies)
Hi ,I have seen this comverters before ,but I was searching today and I can not find them .Is anybody used them before .Any recomendations
Thanks (5 Replies)
I would like to check with grep in this configuration file:
{
"alt-speed-down": 200,
"alt-speed-enabled": true,
"alt-speed-time-begin": 1140,
"alt-speed-time-day": 127,
"...something..." : true,
...
}
"alt-speed-enabled" (the third line of the file) is setted to... (2 Replies)
Hello...
I am new to unix and I am wondering if in a C-shell script , Are we supposed to use only whole numbers........ for example..if a program needs to calculate the average of some numbers........
@ avg = (($1 +$2 + $3)/3)) is returning a whole number.........How can a decimal be achieved... (1 Reply)
Hi People,
I need some Help to write a unix script that asks for a sentence to be typed out then with the sentence. Counts the number of spaces within the sentence and then echo's out "The Number Of Spaces In The Sentence is 4" as a example
Thanks
Danielle (12 Replies)
Hi Everyone,
I'm facing a problem using grep in Cshell.
This is what i'm trying to do:
grep "abc" somefile
VAR="$?"
echo $VAR
somefile contains:
abc
def
ghi
Now, should'nt my output be 0 (Zero)
I'm getting 1 (One)
Can you please help me out.
Thanks in advance :)
G1 (2 Replies)
hi all,
i have a postscript file with duplex print commands. When i print it with
lpr command it prints in duplex.
lpr -pprintername filename.ps
but when i try to print the pages in reverse order with -outputorder=reverse
it is not printing in reverse order (but pages are prited... (0 Replies)
Hello,
I want to know is it possible to pass a block of sentence using bash.
For example,
I have a script called Test.sh that takes in $1 and $2.
and I'm calling Test.sh in a.sh
so
in a.sh
Test.sh '' 'This is a sentence'
Because block are separated by space so when I do that, I get... (6 Replies)