Hi All, I've used regex's in sed before and used a bit of awk, but am unsure of the exact syntax I need here...
I want to do something like:
sed -i 's/restartfreq\([\s]\)*\([0-9]\)*/restartfreq\1$((\2/2))/2/g' \
my_file.conf
where the second match is divided by 2 and then put back in the inline edit.
I've read though that sed can't do math.
Can I do this cleanly with sed or awk alone? Suggestions please.
Edit 1
I thought the meaning of my inquiry was straightforward enough, but I guess I might not have given a good enough sample of the data I want to modify. Here's and example of the line in my *.conf file I want to edit inline:
restartfreq 1250 ;# 2500steps = every 1.25 ps
I've posted a solution below. Both of the answers I received were with regards to printing text to the terminal, not editing a file inline. I try to avoid answering my own question, but in this case neither of the answers I received really did what I requested (edit the file, not just print the edited line) and they were substantially longer than my solution and/or required additional linux programs besides just awk or sed.
I do appreciate the help and feedback, though! :)
NOTE: As my usual disclaimer, this is not a homework question, I am a chemical engineering researcher.