Hi everyone,

I am trying to change hundreds of data files using sed command. Text file1 have 10 lines which look like the following

{ x=34280; y...}
{ x=34281; y...}
{ x=34282; y...}
{ x=34283; y...}
{ x=34284; y...}
{ x=34285; y...}
{ x=34286; y...}
{ x=34287; y...}
{ x=34288; y...}
{ x=34289; y...}

What I like to do is to add 10 times j to each of the x values and print it to the same text file. Here is my trial:

#!/bin/bash

for ((  i = 0 ;  i <= 9;  i++  ))
do
j=1
sed -e   's/'3428$i'/`'3428$i'+10*j`/g'  file1 >  file1_new
mv file1_new file1
done

What I am getting is:

`{ x=34280+10*j`

instead.
any suggestion?

How about something along the lines of

sed -e 's/'3428$i'/'$((3428$i + 10*$j))'/g'

Great. Thanks a lot for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.