![](/img/trans.png)
[英]how to edit a line with an extension in one file from the data of another file in linux
[英]How to edit and move a file from one directory to another in one line in Linux?
新年快樂。 我有個問題。 我想一次將/etc/ansible
目錄中的文件修改並移動到我的主目錄中。
使用sed
命令,我刪除了#
和空行。 現在,我想使用同一命令將ansible.cfg
移至我的主目錄。
~$ sudo sed -i.date +%F '/^\\s*#/d;/^$/d' /etc/ansible/ansible.cfg
您可以使用文件描述符重定向嗎?
~$ sudo sed -i.date +%F '/^\\s*#/d;/^$/d' /etc/ansible/ansible.cfg > /path/to/destination
但是,這不會刪除或更改原始文件。
你可以這樣嘗試。
sudo sed -i.$(date +%F) '/^\s*#/d;/^$/d;w filename-in-your-home' /etc/ansible/ansible.cfg
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.