Topic:
There is a document in the following, write a shell script to achieve the deduplication, reverse order is counted. For example a B c and C B a
A b C
D E F
A D C D E F
C b
C B A
X y Z
X y Z
A b
Z y x
Z X
X y
A D C D
A b C
A b C
A
B
C
Idea: Make an analogy
For example, there's a box containing
2 x Red Balls
2 Green Balls
2 x Blue Balls
How many lines of cc files are cycled
First loop
Now to go heavy, we can randomly take a ball from the inside to another * * empty box (initially empty); equivalent to the flag= ' cat file in the script | Grep-e "$i | $a" ' this line.
When you put it in there is already a ball, the equivalent of Echo $i >> file, and the ball to show, the equivalent of Echo $line
Second cycle
There are two kinds of situations
1 is the red ball.
2 is not a red ball.
If it is a red ball, the first time to take out a red ball, this time again take out a red ball, repeat, directly throw away, do not put it into another box.
If it is not a red ball, take out a red ball for the first time, this time remove not a red ball, do not repeat with the ball in the box, put it into another box.
[email protected] shell]# cat cc.sh #!/bin/bash[!-F file]&&touch filewhile read Linedo i= ' echo $line |sed ' s/ G ' a= ' echo $i |rev ' flag= ' cat file |awk ' {if ($0== "' $i '" | | $0== "' $a '") print "OK"} "if [[" $flag "! =" OK "]];thenecho $lineecho $i >> file fidone< ccrm file
This article is from the "It Life" blog, so be sure to keep this source http://dingxue.blog.51cto.com/12290895/1977696
Shell finishing (====shell) script to go heavy