0

I have a directory with 152 files named plot_1 to plot_152.

In each of those there's some R code with some index [[i]].

Using Kateversion 15.08.2, is it possible to search for [[i]] in each file and replace it with the [[1]] for plot_1 .... [[152]] for plot_152?

If not possible in Kate, is it possible using bash?

2

In bash:

for i in {1...152}
do
    sed -i.bak -e "s/[[i]]/[[$i]]/g plot_$i
done 

This script will run sed on each file, and backup them before replacing the string.

0

Did a little tweak to purplepsycho solution:

for i in {1..152}
do
    sed -i.bak -e "s/[[i]]/[[$i]]]/g" plot_vents_$i
done 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.