I am planning to create a simple script to edit a file based on values stored within a properties file. So essentially I am planning to loop through each line in the original file, when it comes across a certain tag within a line say "/#" it will get the text following the tag i.e. certs and then implement a function to parse through the properties file to get certain values and add them to the original file. So for example the file would have the following line:
"/#certs"
I am not sure how best to search for the tag, I was planning to have an if to find the /# and then split the remaining text to get the string.
while read line
do
#need to parse line to look for tag
echo line >> ${NEW_FILE}
done < ${OLD_FILE}
Any help would e greatly appreciated
=====================================
EDIT:
My explanation was a bit poor; apologies. I am merely trying to get the text following the /# - i.e. I just want to get the string value that precedes it. I can then call a function based on what the text is.
This is portable to Bourne shell and thus, of course, ksh and Bash.
To put it into some sort of context, here is a more realistic example of how you might use it:
For instance you can search for strings and manipulate them in one step using
sed
the stream editor.This will print only the relevant parts after the
/#
of the relevant lines.You can use BASH regex capabilities: