# Copy line from one file into another

**URL:** <https://forum.ansible.com/t/copy-line-from-one-file-into-another/24058>\
**Category:** Ansible Project\
**Created:** [March 24, 2017, 3:48pm UTC](https://forum.ansible.com/t/copy-line-from-one-file-into-another/24058 "2017-03-24T15:48:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![James2](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@James2](https://forum.ansible.com/u/James2)\
**Post date:** [March 24, 2017, 3:48pm UTC](https://forum.ansible.com/t/copy-line-from-one-file-into-another/24058/1 "2017-03-24T15:48:56Z")

</div>

When installing some proprietary software, the documentation instructs me to run a command that creates a new authentication key, which is returned on-screen as standard output. To help automate this I created the following command: /usr/local/bin/atk-key | grep security.user.authToken= | sed -e ‘s/\[1\]\*//’ \> /tmp/auth\_token.txt

The grep command searches for the newly created key, the sed command removes all whitespace in front of the newly created key and then it’s written to a text file. The resulting text file looks something like: security.user.authToken=K8gh578djrh8939Kl/583.

The value of “security.user.authToken=” will obviously change whenever its ran, so I need to configure a playbook that will copy that line from the text file into a configuration file and not be tripped up by the changing value. I’ve looked at lineinfile but am not sure how to configure a task to do what I’m asking. The start of my playbook is below:

* * *

1. \t
