Posts

Showing posts from August 24, 2018

How to use awk to find and replace with calculation? [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP up vote 5 down vote favorite This question already has an answer here: Bash script Multiply only numbers from a text file? 4 answers 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' awk share | improve this question edited Mar 14 at 10:07 David Foerster 915 6 16 asked Mar 14 at 6:48 Zhang Buzz 128 4 marked as duplicate by αғsнιη, Kiwy, Jeff Schaller, elbarna, G-Man Mar 15 at 2:03 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. add a comment  |Â