grep -rl oldtext . | xargs sed -i 's/oldtext/newtext/g'
sed 's/^ *//; s/ *$//; /^$/d; /^\s*$/d' file.txt > output.txt
`s/^ *//` => left trim
`s/ *$//` => right trim
`/^$/d` => remove empty line
`/^\s*$/d` => delete lines which may contain white space
echo " This is a test" | sed -e 's/^[ \t]*//'
If not works, maybe you file have some special not visable charters, like BOM or
M-oM-?M- you can reove them to output to some temporary file and use sed or vi editor to remove them.
sed s/^character-set-server=utf8/#character-set-server=utf8/’ -i /etc/my.cnf
If you want comment on this this line “character-set-server=utf8” on all your servers, you should use something like ansible:
ansible mysql_servers -m shell -a “sed -e ‘s/^character-set-server=utf8/#character-set-server=utf8/’ -i /etc/my.cnf”
sed -ie ‘$d’ some_file.log