Posted to tcl by patthoyts at Wed Sep 20 14:11:10 GMT 2006view raw

  1. # Sed success|failed counter.
  2. #
  3. # A foolish sample to see if sed can manage more that one counter.
  4.  
  5. # Initialize our counters
  6. 1{
  7. x
  8. s/^/S0F0/
  9. x
  10. }
  11.  
  12. # Print the result at the end.
  13. ${
  14. g
  15. p
  16. }
  17.  
  18. /success/{
  19. # get counter digit for the success counter
  20. g
  21. s/S.*\(.\)F.*/\1/
  22. # Increment the hex digit.
  23. y/0123456789abcdef/123456789abcdef0/
  24. # Replace the digit in the counter string.
  25. x
  26. G
  27. s/S\(.*\).F\(.*\)\n\(.\)/S\1\3F\2/
  28. x
  29. }
  30.  
  31. /failed/{
  32. g
  33. s/.*\(.\)/\1/
  34. y/0123456789abcdef/123456789abcdef0/
  35. x
  36. G
  37. s/.\n\(.\)/\1/
  38. x
  39. }
  40.  
  41. # Do not display any lines from the input.
  42. d