title: Copy Bash profile from remote system up to a certain line number point
body: <p>I would like to copy a file from a remote machine onto my local machine, up to the first line containing a certain pattern.</p>
  
  <p>Scenario: update my local Bash profile with a part of the remote Bash profile, up to the point in which my admin has verified it.</p>
  
  <p>Is there a better way (I guess there likely is!) than this quick "shell scripting" hack?</p>
  
  <pre><code>ssh tinosino@robottinosino-wifi cat /Users/tinosino/.profile | sed '/Verify this script further than this point/,$ d' &gt; /home/tinosino/Desktop/tinosino_bash_profile.sh
  </code></pre>
  
  <ul>
  <li>Remote machine: robottinosino-wifi (OSX)</li>
  <li>Sentinel line: Verify this script further than this point</li>
  </ul>
  
  <p>I can use basic shell scripting, preferably in Bash as it's the default, or the most common diff/source-control bins..</p>
  
  <p>The idea, you guess it, is to ultimately automate this process. Cron? Any idea as to how you would do this? The start of my Bash profile should come from the server, the "rest" is free for me to customise.</p>
  
  <p>Prev failed attempts of mine:</p>
  
  <ul>
  <li>using <code>head</code></li>
  <li>using process substituion <code>&lt;( ... )</code></li>
  <li>using <code>grep</code></li>
  <li>using a local named pipe (this was fun: the named pipe needs a program generating its text though, executing something like the cat->sed line above)</li>
  </ul>
  
  <p><strong>Important note</strong>: what would be <em>highly desirable</em> is for the remote system <strong>not</strong> to go through the entire file, but to <em>truncate</em> the filter once it "sees" the sentinel line.. If pattern is in line #300 of 1,000,000,000.. just go over 300 lines.</p>