https://www.php.net/manual/zh/regexp.reference.assertions.php
Last active
June 19, 2019 11:55
-
-
Save sursir/d88ba1d9f6db4cf0615b9fe9d1561e52 to your computer and use it in GitHub Desktop.
ansible replace & add some word char & unique remove duplicate lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.php.net/manual/zh/regexp.reference.assertions.php | |
# https://www.linuxquestions.org/questions/programming-9/ansible-how-to-remove-duplicate-lines-4175654440/ | |
# 补一些缺失的词 | |
ansible busserv --become -m replace -a ' | |
path=/var/spool/cron/root | |
regexp="CmdLog/(?!new/)" | |
replace="CmdLog/new/" | |
' | |
# 文件备份 | |
ansible busserv --become -m copy -a ' | |
src=/var/spool/cron/root | |
dest=/tmp/root_cron_backup_3 | |
remote_src=yes | |
' | |
# 文件内对行去重 | |
# awk '!a[$0]++' source > uniqued_a2 | \cp -f uniqued_a2 source | |
ansible busserv --become -m shell -a ' | |
awk '\''!a[$0]++'\'' /var/spool/cron/root > /tmp/root_cron_uniq_3 | \cp -f /tmp/root_cron_uniq_3 /var/spool/cron/root | |
' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment