How to use sed command with ansible: [<user>@ansible ansible]# ansible -i hosts <group> -m shell -a “sed -i s/fromstring/tostring/ <file>” If do you have special chars, use the \ before these chars. For example: “sed -i s/formsting/stostringwith\|pipe/ <file>”