I have a html file with some variable arrays that I need to increment. I have been doing it by hand – but now is taking up too much of my time. I have been searching and trying to find the correct tool/syntax to do exactly what I want.
say I have:
file[0]=["blah0 blah0", "file0.jpg"]
file[1]=["blah1 blah1", "file1.jpg"]
file[2]=["blah2 blah2", "file2.jpg"]
What I would like to do is have the script add one to the variable number giving me room to add more variables earlier. I could specify 5 and have the result be
file[5]=["blah0 blah0", "file0.jpg"]
file[6]=["blah1 blah1", "file1.jpg"]
file[7]=["blah2 blah2", "file2.jpg"]
This is what I have tried so far – but not much luck… as it removes all the square brackets
awk -F [\]\[] '/^file\[[0-9]+\]=/ {$2="["$2+'$userinput'"]";}1' ${workdirect}/index.html > text.txt
Any advice???
1 Answer