s243a

core/shuffle.awk

Dec 27th, 2020 (edited)
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.54 KB | None | 0 0
  1. #!/usr/bin/gawk -f
  2. BEGIN {
  3.   if (length(shuffle_FS)>0){  
  4.      FS=shuffle_FS
  5.   } else {
  6.     FS="|"
  7.   }
  8.   if (length(shuffle_OFS)>0){
  9.     bla=shuffle_OFS
  10.   } else
  11.   {
  12.     bla="@@@@"
  13.   }
  14.   if ( length(Keep_Key) == 0){
  15.     Keep_Key=false
  16.   }
  17.   OFS=""
  18. }
  19. {
  20.   #print "FS=" FS
  21.   #print "key=" key
  22.   #print "$1=" $1
  23.   if($1 == key) {
  24.     if ( Keep_Key != "true" ){
  25.       $1 = ""
  26.     }
  27.     printf "%s%s", bla, $0
  28.    
  29.   } else {
  30.     if(NR > 1) {
  31.       print ""
  32.     }
  33.     printf "%s", $0
  34.     key = $1
  35.   }
  36. } END {
  37.   print ""
  38. }
  39.  
Add Comment
Please, Sign In to add comment