I am trying to extract two text strings from multiple data files in a directory. I want to separate the text string using a ~ character and send the output to one single file.
Example
directory name: /xmldocs
AND the filenames are name of files: 1.xml
, 2.xml
, 3.xml
Expected Output:
TEXT_STRING_ONE~TEXT_STRING_TWO ------- This is from 1.xml
TEXT_STRING_ONE~TEXT_STRING_TWO ------- This is from 2.xml
TEXT_STRING_ONE~TEXT_STRING_TWO ------- This is from 3.xml
SCRIPT used kind of works with only one grep command
for i in `ls`
do
grep "Document ID:" $i
echo "~"
echo "\n"
done >> /xmldocs/1.txt
When I insert the 2nd grep command; grep 'CI[^"]'
the script hangs and there is no output.
Current Output is
<KMS_data id="KMS_documentId" name="Document ID:">12</KMS_data>
~
<KMS_data id="KMS_documentId" name="Document ID:">19</KMS_data>
~
<KMS_data id="KMS_documentId" name="Document ID:">6</KMS_data>
~
grep "Document ID:" $i
~
grep "Document ID:" $i
~
grep "Document ID:" $i > /xmldocs/1.txt
~
Any help is appreciative. I am very very new with LINUX/UNIX commands and I need to extract the information from 20,000 xml files. Thanks.