Artificial intelligent assistant

How to use awk to find and replace with calculation? I have several CSS files under a folder contains `0.2rem` or `0.5rem 0.6rem`, now I want them to be all divided by 2, become `0.1rem` and `0.25rem, 0.3rem`. How can I use `awk` or `sed` or `gawk` to accomplish this? I tried the following command but have no success: find . -name "*.css" | xargs gawk -i inplace '{gsub(/([0-9\.]+)rem/, "(\\1 * 0.5)rem"); print $0}'

**`find`** \+ GNU **`awk`** solution:


find . -type f -name "*.css" -exec gawk -i inplace \
'{ for (i=1; i<=NF; i++)
if ($i ~ /^[0-9]+\.[0-9]+rem/) { v=$i/2; sub(/^[0-9]+\.[0-9]+/, "", $i); $i=v $i }
}1' {} \;

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 6231652f4045a0d29b756866c042d252