You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
5.5KB

  1. <html>
  2. <head>
  3. <title>Treesed Usage</title>
  4. </head>
  5. <body>
  6. <table border="0" width="660" cellpadding="0" cellspacing="0">
  7. <tbody><tr valign="top"><td width="165">
  8. <h3>How to Use Treesed</h3>
  9. Go to the directory where you want to search or make changes.
  10. <p>
  11. There are two choices you can make when using treesed:
  12. </p><ol>
  13. <li>Do I just want to search for a text, or do I want to search for a
  14. text and replace it with something else?
  15. <br>
  16. If you are just searching you are using Treesed in "search mode", otherwise it is in
  17. "replace mode."
  18. </li><li>Do I want to search/replace only in files in my current directory,
  19. or should files in all subdirectories (and all directories below that)
  20. also be done?
  21. </li></ol>
  22. Some examples will make this clear.
  23. <h4>Searching</h4>
  24. Say you are faced with the situation that the author of a slew of web-pages, Nathan Brazil, has left and has been succeeded by Mavra Chang. First, let us see which files are affected by this (what you type in is shown in <b><tt>bold</tt></b>):
  25. <blockquote>
  26. <pre>[localhost] <b>treesed "Nathan Brazil" -files *.html</b>
  27. search_pattern: Nathan\ Brazil
  28. replacement_pattern:
  29. ** Search mode
  30. .
  31. midnight.html: 1 lines on: 2
  32. ..
  33. well.html: 1 lines on: 3
  34. </pre>
  35. </blockquote>
  36. We notice the following:
  37. <ul>
  38. <li>The search text <tt>"Nathan Brazil"</tt> is enclosed in
  39. double-quotes (<tt>"</tt>).
  40. </li><li>You specify which files to search with <tt>-files</tt> followed by a
  41. list of file names--in this case <tt>*.html</tt>.
  42. </li><li>Treesed reports the search pattern ("pattern" is just a fancy word
  43. for "text") you specified (you can ignore
  44. that \).
  45. </li><li>Treesed reports an empty <tt>replacement_pattern</tt>. This is
  46. correct, because you haven't entered one.
  47. </li><li>It therefore deduces that is is in search mode.
  48. </li><li>It finds two files containing "Nathan Brazil", and reports on which
  49. lines of these files it found it; it does not show the lines themselves.
  50. </li></ul>
  51. Because you used <tt>-files</tt>, Treesed will search in the files you
  52. specify <i>in the current directory</i>. You can also search files in
  53. the current directory <i>and</i> all directories below it. However, in
  54. that case you can not specify which file names to use, all files will be
  55. searched:
  56. <blockquote>
  57. <pre>[localhost] <b>treesed "Nathan Brazil" -tree</b>
  58. search_pattern: Nathan\ Brazil
  59. replacement_pattern:
  60. ** Search mode
  61. .
  62. midnight.html: 1 lines on: 2
  63. ...
  64. well.html: 1 lines on: 3
  65. .
  66. new/echoes.html: 1 lines on: 2
  67. </pre>
  68. </blockquote>
  69. We notice the following:
  70. <ul>
  71. <li>Instead of <tt>-files</tt> we now see <tt>-tree</tt>.
  72. </li><li>We do not see a specification of file names.
  73. </li><li>Treesed finds an occurence of "Nathan Brazil" in the file
  74. <tt>echoes.html</tt> in the subdirectory <tt>new</tt>; it did not
  75. find this file in the previous example (as it shouldn't).
  76. </li></ul>
  77. <h4>Replacing</h4>
  78. To replace a text you simply add the replacement text right after the
  79. search text:
  80. <blockquote>
  81. <pre>[localhost] <b>treesed "Nathan Brazil" "Mavra Change" -files *.html</b>
  82. search_pattern: Nathan\ Brazil
  83. replacement_pattern: Mavra Chang
  84. ** EDIT MODE!
  85. .
  86. midnight.html: 1 lines on: 2
  87. Replaced Nathan\ Brazil by Mavra Chang on 1 lines in midnight.html
  88. ..
  89. well.html: 1 lines on: 3
  90. Replaced Nathan\ Brazil by Mavra Chang on 1 lines in well.html
  91. </pre>
  92. </blockquote>
  93. We notice the following:
  94. <ul>
  95. <li>Right after the search text "Nathan Brazil" you specify the
  96. replacement text "Mavra Chang".
  97. </li><li>As a result, Treesed now reports a non-empty
  98. <tt>replacement_pattern</tt>.
  99. </li><li>Hence it concludes it is in "edit mode", which means replacment mode.
  100. </li><li>Treesed dutifully reports on which lines in which files it did the
  101. replacement.
  102. </li></ul>
  103. To replace a text in all files in the current directory and the ones
  104. below it, we do the following:
  105. <blockquote>
  106. <pre>[localhost] <b>treesed "Nathan Brazil" "Mavra Chang" -tree</b>
  107. search_pattern: Nathan\ Brazil
  108. replacement_pattern: Mavra Chang
  109. ** EDIT MODE!
  110. .
  111. midnight.html: 1 lines on: 2
  112. Replaced Nathan\ Brazil by Mavra Chang on 1 lines in midnight.html
  113. ....
  114. well.html: 1 lines on: 3
  115. Replaced Nathan\ Brazil by Mavra Chang on 1 lines in well.html
  116. .
  117. new/echoes.html: 1 lines on: 2
  118. Replaced Nathan\ Brazil by Mavra Chang on 1 lines in new/echoes.html
  119. </pre>
  120. </blockquote>
  121. and we get the expected results, including the replace in
  122. <tt>new/echoes.html</tt>.
  123. <h4>Old Versions</h4>
  124. Treesed leaves behind quite a mess of old versions of the files it
  125. changed (only in change-mode, of course). These old files have the same
  126. name as the original file, with <tt>.ddddd</tt> appended to it. For
  127. example, if treesed makes a change to <tt>midnight.html</tt> it will
  128. leave the original version as something like
  129. <tt>midnight.html.26299</tt>. You'll have to remove these files lest
  130. your disk area clutters up. Here is a command that does that, <b>but
  131. beware!</b> This command removes all files in the current directory and
  132. all below it, that end in a period followed by one or more
  133. digits:
  134. <blockquote>
  135. <pre>find . -name "*.[0-9]*" -exec rm {} \;
  136. </pre>
  137. </blockquote>
  138. It is interesting to note that if you use treesed again without cleaning
  139. up, you may get files like <tt>midnight.html.26299.27654</tt>. These
  140. will also be cleaned up by the above slightly dangerous command.
  141. <h3>About Treesed</h3>
  142. <tt>treesed</tt> is public domain software developed
  143. and designed by Rick Jansen from Sara, Amsterdam, Netherlands, January
  144. 1996.
  145. <p>
  146. <h3>About This Document</h3>
  147. This usage document was created by the Division of Information Technology Services at The
  148. University of Western Ontario.
  149. </body></html>