I am trying to read a file in Linux and as soon as a "&" character is encountered, I am writing the output to another file, sending that file to another folder and then continuing to read the original file till next "&" and so on
Input xml file-
<Document> <tag1> <tag2> </Document> & <Document> <tag3> <tag4> </Document> & <Document> <tag5> <tag6> </Document> My code snippet -
while IFS= read -r line;do if [["$line" =="$delimeter"]];then echo "$line" | sed "s/delimeter.*//">> "$output_file" cp "$output_file" "$TARGET_FOLDER" break else echo "$line" >> "$output_file" fi done < "$input_file" However, the code is producing the entire file as the output instead of splitting by occurrence of delimeter, can I please be directed towards where I'm going wrong?
Expected Output - The first <Document> to </Document> (till &) section is put in output file, which is copied to TARGET_FOLDER. Then the next <Document> to </Document> section is copied and so on.
Thankyou for your help!