In the process of doing keyword cleaning, you need to filter out a class of words that do not conform to the end of a word, the idea is to put this batch of words according to the last word sort, so think of the first of these words to reverse, such as the 12345 to 54321, as if in the night interest in the article looked at the shell can be realized, Baidu a bit, Find out a few possible solutions, now record.
Shell implementation string inversion, a command to fix!
Copy Code code as follows:
Cat Keywords.txt|while Read Line;do echo $line |rev;done
Ordered by:
Copy Code code as follows:
Python's:
Copy Code code as follows:
echo 12345|python-c ' Print raw_input () [::-1] '
SED's:
Copy Code code as follows:
Echo 12345|sed '/\n/! G;s/\ (. \) \ (. *\n\)/&\2\1/;//d;s/.//'
Awk's:
Copy Code code as follows:
echo 12345|awk ' begin{fs= '}{for (a=nf;a>0;a–) printf ("%s", a==1? $a "\ n": $a)} '
For pure bash:
Copy Code code as follows:
Echo 12345| {read;for (i=${#REPLY};i>0;i–)) do Echo-n "${reply:$[i-1]:1}";d One;echo;
C's:
Copy Code code as follows:
Gcc-o a-o2-x C < (cat <<! #include <stdio.h> #include <stdlib.h> #include <string.h> int main (int Argc,char *argv[]) {if (argc!= 2) {printf ("%s reverse lines of a string\n", argv[0]); exit (1);} int i=0; char *p; p=argv[1]; I=strlen (argv[ 1])-1; for (i;i>=0;i--) {printf ("%s%s", &p[i], (i==0)? " \ n ":"); P[i]= ' "; &&/a "12345"; Rm-f a