fork download
  1. #!/bin/sh
  2. # http://stackoverflow.com/questions/30299516/split-file-into-several-sub-files
  3.  
  4. t=$(mktemp -t -d) || exit 127
  5. trap 'rm -rf "$t"' EXIT
  6. trap 'exit 126' HUP QUIT TERM
  7.  
  8. cd "$t"
  9.  
  10. awk '!body && /^\/\/$/ {body=1}
  11. body && sub(/^gthcont: */,"") {print > "second_"FILENAME}
  12. body && /^[01]+/ {print > "third_"FILENAME}
  13. body && /^\[[0-9]+\]/ {
  14. print > "first_"FILENAME
  15. print substr($0, 2, index($0,"]")-2) > "fourth_"FILENAME
  16. }'
  17.  
  18. tail *
Success #stdin #stdout 0s 5872KB
stdin
header
//
[25]:0.00843832,469:0.0109533):0.00657864,((((872:0.00120503,((980:0.0001);
[29]:((962:0.000580339,930:0.000580339):0.00543993);
absolute:
gthcont: 5 4 2 1 3 4 543 5  67 657  78 67 8  5645 6 
01010010101010101010101010101011111100011
1111010010010101010101010111101000100000
00000000000000011001100101010010101011111
stdout
==> first_- <==
[25]:0.00843832,469:0.0109533):0.00657864,((((872:0.00120503,((980:0.0001);
[29]:((962:0.000580339,930:0.000580339):0.00543993);

==> fourth_- <==
25
29

==> second_- <==
5 4 2 1 3 4 543 5  67 657  78 67 8  5645 6 

==> third_- <==
01010010101010101010101010101011111100011
1111010010010101010101010111101000100000
00000000000000011001100101010010101011111