Sample Header Ad - 728x90

Parse txt file on basis of occurrence of a tag in Linux

-2 votes
1 answer
73 views
I am trying to parse a txt file containing xml "messages"in linux, something like this
xyz     xyz     xyz     xyz   and so on
The code will read file, extract each section from
till
and put each section into a separate file. My code for this is as below
input_file="input_file.txt"

# Extracting Document parts
sed -n '//p' "$input_file" > temp_output.txt

# Splitting into Different Files
csplit -f output -b %d.txt -z temp_output.txt '//' '{*}'

# Cleaning up temporary files
rm temp_output.txt
However, this code is extracting several xml messages into one file, particularly the ones with no line break. Could someone suggest what can be rectified in the above code?
Asked by python6 (1 rep)
May 15, 2024, 01:29 PM
Last activity: May 15, 2024, 02:09 PM