title: Compare many text files that contain duplicate "stubs" from the previous and next file and remove duplicate text automatically
body: <p>I have a large number of text files (1000+) each containing an article from an academic journal. Unfortunately each article's file also contains a "stub" from the end of the previous article (at the beginning) and from the beginning of the next article (at the end). </p>
  
  <p>I need to remove these stubs in preparation for running a frequency analysis on the articles because the stubs constitute duplicate data.</p>
  
  <p>There is no simple field that marks the beginning and end of each article in all cases. However, the duplicate text does seem to formatted the same and on the same line in both cases.</p>
  
  <p>A script that compared each file to the next file and then removed 1 copy of the duplicate text would be perfect. This seems like it would be a pretty common issue when programming so I am surprised that I haven't been able to find anything that does this.</p>
  
  <p>The file names sort in order, so a script that compares each file to the next sequentially should work. E.G.</p>
  
  <pre>
  bul_9_5_181.txt
  bul_9_5_186.txt
  </pre>
  
  <p>are two articles, one starting on page 181 and the other on page 186. Both of these articles are included bellow. </p>
  
  <p>There is two volumes of test data located at [<a href="http://drop.io/fdsayre][1]" rel="nofollow noreferrer">http://drop.io/fdsayre][1]</a></p>
  
  <p>Note: I am an academic doing content analysis of old journal articles for a project in the history of psychology. I am no programmer, but I do have 10+ years experience with linux and can usually figure things out as I go. </p>
  
  <p>Thanks for your help</p>
  
  <p><b>FILENAME: bul_9_5_181.txt</b></p>
  
  <p>
  SYN&amp;STHESIA</p>
  
  <p>ISI</p>
  
  <p>the majority of Portugese words signifying black objects or ideas relating to black. This association is, admittedly, no true synsesthesia, but the author believes that it is only a matter of degree between these logical and spontaneous associations and genuine cases of colored audition.
  REFERENCES</p>
  
  <p>DOWNEY, JUNE E. A Case of Colored Gustation. Amer. J. of Psycho!., 1911, 22, S28-539MEDEIROS-E-ALBUQUERQUE. Sur un phenomene de synopsie presente par des millions de sujets. / . de psychol. norm, et path., 1911, 8, 147-151. MYERS, C. S. A Case of Synassthesia. Brit. J. of Psychol., 1911, 4, 228-238.</p>
  
  <p>AFFECTIVE PHENOMENA — EXPERIMENTAL
  BY PROFESSOR JOHN F. .SHEPARD
  University of Michigan</p>
  
  <p>Three articles have appeared from the Leipzig laboratory during the year. Drozynski (2) objects to the use of gustatory and olfactory stimuli in the study of organic reactions with feelings, because of the disturbance of breathing that may be involved. He uses rhythmical auditory stimuli, and finds that when given at different rates and in various groupings, they are accompanied by characteristic feelings in each subject. He records the chest breathing, and curves from a sphygmograph and a water plethysmograph. Each experiment began with a normal record, then the stimulus was given, and this was followed by a contrast stimulus; lastly, another normal was taken. The length and depth of breathing were measured (no time line was recorded), and the relation of length of inspiration to length of expiration was determined. The length and height of the pulsebeats were also measured. Tabular summaries are given of the number of times the author finds each quantity to have been increased or decreased during a reaction period with each type of feeling. The feeling state accompanying a given rhythm is always complex, but the result is referred to that dimension which seemed to be dominant. Only a few disconnected extracts from normal and reaction periods are reproduced from the records. The author states that excitement gives increase in the rate and depth of breathing, in the inspiration-expiration ratio, and in the rate and size of pulse. There are undulations in the arm volume. In so far as the effect is quieting, it causes decrease in rate and depth of</p>
  
  <p>182</p>
  
  <p>JOHN F. SHEPARD</p>
  
  <p>breathing, in the inspiration-expiration ratio, and in the pulse rate and size. The arm volume shows a tendency to rise with respiratory waves. Agreeableness shows</p>