SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 243 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. AA|BB|CC  
  2. a@gmail.com,c@yahoo.co.in|a@gmail.com|a@gmail.com
  3. y@gmail.com|x@yahoo.in,z@redhat.com|z@redhat.com
  4. c@gmail.com|b@yahoo.co.in|c@uix.xo.in
  5.    
  6. c@yahoo.co.in|a@gmail.com|  
  7. y@gmail.com|x@yahoo.in|z@redhat.com  
  8. c@gmail.com|b@yahoo.co.in|c@uix.xo.in
  9.    
  10. cat file | tr ',' '|' | awk -F '|' '{ line=""; for (i=1; i<=NF; i++) {if ($i != "" && list[NR"@"$i] != 1){line=line $i "|"}; list[NR"@"$i]=1 }; print line}'
  11.    
  12. a@gmail.com|c@yahoo.co.in|
  13. y@gmail.com|x@yahoo.in|z@redhat.com|
  14. c@gmail.com|b@yahoo.co.in|c@uix.xo.in|
  15.    
  16. a@gmail.com|c@yahoo.co.in|
  17. y@gmail.com|x@yahoo.in|a@gmail.com|
  18. c@gmail.com|c@yahoo.co.in|c@uix.xo.in|
  19.    
  20. a@gmail.com|c@yahoo.co.in|
  21. y@gmail.com|x@yahoo.in|a@gmail.com|
  22. c@gmail.com|c@yahoo.co.in|c@uix.xo.in|
  23.    
  24. #!/usr/bin/env python
  25. while True:
  26.     try:
  27.         addrs = raw_input()
  28.     except EOFError:
  29.         break
  30.     print '|'.join(set(addrs.replace(',', '|').split('|')))
  31.    
  32. {
  33.     for(i=1; i < NF; i++) {
  34.         if ($i ~ /@/) {
  35.             mail[$i]++
  36.         }
  37.     }
  38. }
  39. END {
  40.     for (x in mail) {
  41.         print mail[x], x
  42.     }
  43. }
  44.    
  45. $ awk -F'[|,]' -f v.awk f1
  46. 2 z@redhat.com
  47. 3 a@gmail.com
  48. 1 x@yahoo.in
  49. 1 c@yahoo.co.in
  50. 1 c@gmail.com
  51. 1 y@gmail.com
  52. 1 b@yahoo.co.in
  53.    
  54. while read s; do
  55.   IFS='|,'
  56.   for e in $s; do
  57.     echo "$e"
  58.   done | sort | uniq
  59.   unset IFS
  60. done
  61.    
  62. BEGIN {IFS=/[,|]/}
  63.  
  64. NF {
  65.     delete uniqmails;
  66.     for (i=1; i<=NF; i++)
  67.         uniqmails[$i] = 1;
  68.     sep="";
  69.     n=0;
  70.     for (m in uniqmails) {
  71.         printf "%s%s", sep, m;
  72.         sep="|";
  73.         n++;
  74.     }
  75.     for (;n<3;n++) printf "|";
  76.     print ""; // EOL
  77. }
  78.    
  79. while read line; do
  80.     echo $line | tr ",|" "n"  | sort -u |
  81.     paste <( seq 3) - | cut -f 2 |
  82.     tr "n" "|" |
  83.     rev | cut -c 2- | rev;
  84. done
  85.    
  86. perl -lane '$s{$_}++ for split /[|,]/; END { print for keys %s;}' input
  87.    
  88. while read line
  89.     do
  90.     val1=`echo $line|awk -F"|" '{print $1}'`
  91.     val2=`echo $line|awk -F"|" '{print $2}'`
  92.     val3=`echo $line|awk -F"|" '{print $3}'`
  93.  
  94.  
  95.     a=`echo $line|awk -F"|" '{print $2,"|",$3}'|sed 's/'$val1'//g'`
  96.     aa=`echo "$val1|$a"`
  97.  
  98.     b=`echo $aa|awk -F"|" '{print $1,"|",$3}'|sed 's/'$val2'//g'`
  99.     b1=`echo $b|awk -F"|" '{print $1}'`
  100.     b2=`echo $b|awk -F"|" '{print $2}'`
  101.     bb=`echo "$b1|$val2|$b2"`
  102.     c=`echo $bb|awk -F"|" '{print $1,"|",$2}'|sed 's/'$val3'//g'`
  103.     cc=`echo "$c|$val3"|sed 's/,,/,/;s/,|/|/;s/|,/|/;s/^,//;s/ //g'`
  104.     echo "$cc">>abcd
  105.  
  106.     done<ab.dat
  107.    
  108. c@yahoo.co.in||a@gmail.com
  109. y@gmail.com|x@yahoo.in|z@redhat.com
  110. c@gmail.com|b@yahoo.co.in|c@uix.xo.in
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top