I'm writing the shell script that should process through some text, I've got the text like that:
read build { file1 file2 file3 }
check build { file2 file3 file4 }
read build { file4 file5 file6 }
I want to add some text before all files - that means words, that are included between brackets in 'read build' lines, what do you think is the best idea to achieve that? The results should look like that:
read build { MY_ADDED_WORDfile1 MY_ADDED_WORDfile2 MY_ADDED_WORDfile3 }
check build { file2 file3 file4 }
read build { MY_ADDED_WORDfile4 MY_ADDED_WORDfile5 MY_ADDED_WORDfile6 }
I was trying with greping that lines, next parsing it to array and concatenate this "file" strings with the word I want to add, but I think that is not a "smart" solution. Thanks for your help.
Input files look like this:
set build { file1 file2 file3 file4 }
check $build
read build -new -f $build
read build -new -f { fileA fileB fileC fileD }
set build {file5 file6 file7 }
read build -old -f $build
read build -old -f { fileX fileZ fileD }
check_that_building
Output should look like that:
set build { file1 file2 file3 file4 }
check $build
read build -new -f $build
read build -new -f { MY_ADDED_WORDfileA MY_ADDED_WORDfileB MY_ADDED_WORDfileC MY_ADDED_WORDfileD }
set build {file5 file6 file7 }
read build -old -f $build
read build -old -f { MY_ADDED_WORDfileX MY_ADDED_WORDfileZ MY_ADDED_WORDfileD }
check_that_building
There is always a space before opening bracket but it can be a situation that there will be not a space after opening bracket, there can a space before closing bracket but it's not always. Possible cases:
read build -old -f { fileX fileZ fileD }
read build -old -f {fileX fileZ fileD }
read build -old -f { fileX fileZ fileD}
read build -old -f {fileX fileZ fileD}