title: Python + cmd line string manipulation what should I have done diferently
body: <p>I am pretty new to programming in general and watching CTF videos has inspired me to start out with python and having a good grasp on the command line (I am on OSX btw).
  In the past I used anaconda's spyder environment for school (Python 2.7).
  As I was setting up brew, pip and python I realized I had a bunch of packages from Anaconda for 2.7 on pip but none for 3.6 on pip3.
  I decided to <code>pip list</code> and got a table of all the (many) packages anaconda installed for me.
  This is what you get :</p>
  
  <pre><code>    Package                            Version                
  ---------------------------------- -----------------------
  alabaster                          0.7.10                 
  anaconda-client                    1.6.5                  
  anaconda-navigator                 1.6.8                  
  anaconda-project                   0.8.0                  
  appnope                            0.1.0                  
  appscript                          1.0.1                  
  asn1crypto                         0.22.0                 
  astroid                            1.5.3                  
  astropy                            2.0.2                  
  Babel                              2.5.0                  
  backports-abc                      0.5                    
  backports.functools-lru-cache      1.4                    
  backports.shutil-get-terminal-size 1.0.0                  
  backports.ssl-match-hostname       3.5.0.1                
  beautifulsoup4                     4.6.0                  
  bitarray                           0.8.1    
  ...
  </code></pre>
  
  <p>I then had the idea:
  Can I convert this text to a string in this format.
  "Package1 Package2 Package3 Package4" so I can pip3 all the packages.
  <strong>This became a string manipulation challenge as I realized it probably isn't effective to just pip3 install 150+ packages and faster to just download anaconda for 3.7.(Compatibility, useless, time consuming...)</strong></p>
  
  <p>So i started by extracting the list with ">" in the terminal to a new file I made
   I then removed the first two lines with the tail function in the terminal.
  What could I have done with python I tried many things but it never worked and found this which killed all motivation to debug/think.</p>
  
  <pre><code>tail -n +2 "$FILE" &gt; "$FILE.tmp" &amp;&amp; mv "$FILE.tmp" "$FILE"
  </code></pre>
  
  <p>After that I made this simple python script to convert to the format I was looking for by removing all the versions and making them one single string.</p>
  
  <pre><code>with open("file.txt","r+") as f:
      lines=f.readlines()
      new_string=''
      for i in range(len(lines)):
          lines[i]=lines[i].split(" ", 1)
          del lines[i][1]
          new_string += lines[i][0] + ' '
  
  
      print new_string
  </code></pre>
  
  <p>Please let me know if there is anything I could have done in the terminal window or why my python script is bad.
  My for loop IMO seems kind of bizarre with the <code>i</code> and the <code>lines[i][0]</code> is ugly IMO because you don't naturally grasp what it means.</p>
  
  <p>Any help or different  method would be highly appreciated.
  Many thanks in advance.</p>
  
  <p>**TLDR:
  Any insight on:</p>
  
  <p>1)simple way to remove n first lines of a txt file with python or terminal</p>
  
  <p>2)Why is my Python code ugly , is there a terminal equivalent??**</p>