fork download
  1. #!/bin/bash
  2.  
  3. echo "Vel RMSE H D20120122 D20130404 X Y
  4. 0.5 0.1 3 4 5 2 2
  5. 0.5 0.1 3 test4 test5 2 2
  6. 6 7 8 9" | awk '
  7. BEGIN { ORS="" };
  8. {
  9. if (NR==1) {
  10. for(i=1; i<=NF; i++) {
  11. if($i ~ /D2/) {
  12. arr[++keyNr] = i
  13. }
  14. }
  15. }
  16. for (y=1; y<=keyNr; y++) {
  17. printf("%-10s", $arr[y])
  18. }
  19. print "\n"
  20. }'
Success #stdin #stdout 0.01s 5464KB
stdin
Standard input is empty
stdout
D20120122 D20130404 
4         5         
test4     test5     
9