Reputation: 51
Happy new year.
I have a question.
I want to modify and move a file in /etc/ansible
directory to my home directory in one shot.
With sed
command i removed the #
and empty lines. Now I want to move ansible.cfg
to my home directory in the same command.
~$ sudo sed -i.date +%F '/^\s*#/d;/^$/d' /etc/ansible/ansible.cfg
Upvotes: 0
Views: 603
Reputation: 2491
You can try like that.
sudo sed -i.$(date +%F) '/^\s*#/d;/^$/d;w filename-in-your-home' /etc/ansible/ansible.cfg
Upvotes: 1
Reputation: 53
Can you use a file descriptor redirection?
~$ sudo sed -i.date +%F '/^\s*#/d;/^$/d' /etc/ansible/ansible.cfg > /path/to/destination
This won't remove or change the original file, however.
Upvotes: 1