title: From AWS CLIi pipe output to existing file on specific line
body: <p>I'm currently working on writing an Ansible Playbook and i'm looking for a command that gets AWS private IP addresses and place them in an existing file on an exact line.</p>
  
  <p>I'm able to do the first part:</p>
  
  <pre><code>aws ec2 describe-instances --filters "Name=tag:Name,Values=ams*" "Name=instance-state-name,Values=running" --query "Reservations[].Instances[][PrivateIpAddress]" 
  </code></pre>
  
  <p>However I'd like to pipe that to a file (inventory.ini) starting on line 2</p>
  
  <p>I'm thinking I should use <code>sed</code> and <code>awk</code> but I cant figure out how to pass variables into those utilities.  I would like to do this all in one command - something like:</p>
  
  <pre><code>aws command | sed -i '' '2s/.*/[command output]/' inventory.ini
  </code></pre>