Найти файлы XML, не содержащие определенный комментарий из оболочки

Я хочу искать (awk / grep / sed) в нескольких файлах XML (файл pom.xml), пропуская какую-то папку. Более того, первое условие состоит в том, что они должны содержать тег<module>, Для этих случаев я хочу распечатать тех, кто не содержит точно приведенную ниже последовательность (это автоматически сгенерированный код - это поможет мне определить, изменил ли кто-нибудь эту последовательность):

  <!--
         | Start of user code (user defined modules)
         |-->
        <!-- 
         | End of user code
         |-->

Я застрял здесь:

        fileArray=($(find . -type f -not -path "./folder1/*" -not -path "*/folder2/*" -not -path "./folder3/*" -name "pom.xml" \
                    | xargs awk -v RS='^

Несколько советов, пожалуйста?

---ОБНОВИТЬ:

  #!/bin/sh

###########################################################
# Checks for "user code" <modules> defined in pom files.
###########################################################

function check()
{
              # http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html

        OLDIFS=$IFS
        IFS=

---- ОБНОВЛЕНИЕ (последний вывод консоли)

    :~/temp> bash script.sh
awk: cmd. line:1: fatal: cannot open file `{}' for reading (No such file or directory)
ERROR:Found user code modules (file:line:occurrence): ./test_folder/test4/pom.xml ./tes                                                                        t_folder/test1/pom.xml ./test_folder/test2/pom.xml ./test_folder/test3/pom.xml
SUMMARY:Found 1 pom.xml file(s) containing user code modules.
'match($0,/\<module>[^\n]+/,a){print a[0]}'))

Несколько советов, пожалуйста?

---ОБНОВИТЬ:

  #!/bin/sh

###########################################################
# Checks for "user code" <modules> defined in pom files.
###########################################################

function check()
{
              # http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html

        OLDIFS=$IFS
        IFS=$'\n'

        # Read all pom files into an array
        # - Search for user code modules: It searches for the tag <module> into the pom files and in case they contain modules,
        #checks if the autogenerated section has been modified. Reading text secuence from foo.txt file
        #
        # - Exclude model folder as the codegen poms therein require such a repository



        fileArray=($(find . -type f -not -path "./folder1/*" -not -path "*/folder2/*" -not -path "./folder3/*" -name "pom.xml" \
                         | xargs `awk -v RS='^$' 'NR==FNR{str=$0;next} /<module>/ && !index($0,str){print FILENAME}' sequence {} +`))


        IFS=$OLDIFS

        # get length of an array
        numberOfFiles=${#fileArray[@]}

        # read all filenames
        for (( i=0; i<${numberOfFiles}; i++ ));
        do
          echo "ERROR:Found user code modules (file:line:occurrence): ${fileArray[$i]}"
        done


    if [ "$numberOfFiles" != "0" ]; then
        echo "SUMMARY:Found $numberOfFiles pom.xml file(s) containing user code modules."
        exit 1
    fi
}

check

---- ОБНОВЛЕНИЕ (последний вывод консоли)

    :~/temp> bash script.sh
awk: cmd. line:1: fatal: cannot open file `{}' for reading (No such file or directory)
ERROR:Found user code modules (file:line:occurrence): ./test_folder/test4/pom.xml ./tes                                                                        t_folder/test1/pom.xml ./test_folder/test2/pom.xml ./test_folder/test3/pom.xml
SUMMARY:Found 1 pom.xml file(s) containing user code modules.
\n' # Read all pom files into an array # - Search for user code modules: It searches for the tag <module> into the pom files and in case they contain modules, #checks if the autogenerated section has been modified. Reading text secuence from foo.txt file # # - Exclude model folder as the codegen poms therein require such a repository fileArray=($(find . -type f -not -path "./folder1/*" -not -path "*/folder2/*" -not -path "./folder3/*" -name "pom.xml" \ | xargs `awk -v RS='^

---- ОБНОВЛЕНИЕ (последний вывод консоли)

    :~/temp> bash script.sh
awk: cmd. line:1: fatal: cannot open file `{}' for reading (No such file or directory)
ERROR:Found user code modules (file:line:occurrence): ./test_folder/test4/pom.xml ./tes                                                                        t_folder/test1/pom.xml ./test_folder/test2/pom.xml ./test_folder/test3/pom.xml
SUMMARY:Found 1 pom.xml file(s) containing user code modules.
'match($0,/\<module>[^\n]+/,a){print a[0]}'))

Несколько советов, пожалуйста?

---ОБНОВИТЬ:

  #!/bin/sh

###########################################################
# Checks for "user code" <modules> defined in pom files.
###########################################################

function check()
{
              # http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html

        OLDIFS=$IFS
        IFS=$'\n'

        # Read all pom files into an array
        # - Search for user code modules: It searches for the tag <module> into the pom files and in case they contain modules,
        #checks if the autogenerated section has been modified. Reading text secuence from foo.txt file
        #
        # - Exclude model folder as the codegen poms therein require such a repository



        fileArray=($(find . -type f -not -path "./folder1/*" -not -path "*/folder2/*" -not -path "./folder3/*" -name "pom.xml" \
                         | xargs `awk -v RS='^$' 'NR==FNR{str=$0;next} /<module>/ && !index($0,str){print FILENAME}' sequence {} +`))


        IFS=$OLDIFS

        # get length of an array
        numberOfFiles=${#fileArray[@]}

        # read all filenames
        for (( i=0; i<${numberOfFiles}; i++ ));
        do
          echo "ERROR:Found user code modules (file:line:occurrence): ${fileArray[$i]}"
        done


    if [ "$numberOfFiles" != "0" ]; then
        echo "SUMMARY:Found $numberOfFiles pom.xml file(s) containing user code modules."
        exit 1
    fi
}

check

---- ОБНОВЛЕНИЕ (последний вывод консоли)

    :~/temp> bash script.sh
awk: cmd. line:1: fatal: cannot open file `{}' for reading (No such file or directory)
ERROR:Found user code modules (file:line:occurrence): ./test_folder/test4/pom.xml ./tes                                                                        t_folder/test1/pom.xml ./test_folder/test2/pom.xml ./test_folder/test3/pom.xml
SUMMARY:Found 1 pom.xml file(s) containing user code modules.
'NR==FNR{str=$0;next} /<module>/ && !index($0,str){print FILENAME}' sequence {} +`)) IFS=$OLDIFS # get length of an array numberOfFiles=${#fileArray[@]} # read all filenames for (( i=0; i<${numberOfFiles}; i++ )); do echo "ERROR:Found user code modules (file:line:occurrence): ${fileArray[$i]}" done if [ "$numberOfFiles" != "0" ]; then echo "SUMMARY:Found $numberOfFiles pom.xml file(s) containing user code modules." exit 1 fi } check

---- ОБНОВЛЕНИЕ (последний вывод консоли)

    :~/temp> bash script.sh
awk: cmd. line:1: fatal: cannot open file `{}' for reading (No such file or directory)
ERROR:Found user code modules (file:line:occurrence): ./test_folder/test4/pom.xml ./tes                                                                        t_folder/test1/pom.xml ./test_folder/test2/pom.xml ./test_folder/test3/pom.xml
SUMMARY:Found 1 pom.xml file(s) containing user code modules.
'match($0,/\<module>[^\n]+/,a){print a[0]}'))

Несколько советов, пожалуйста?

---ОБНОВИТЬ:

  #!/bin/sh

###########################################################
# Checks for "user code" <modules> defined in pom files.
###########################################################

function check()
{
              # http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html

        OLDIFS=$IFS
        IFS=$'\n'

        # Read all pom files into an array
        # - Search for user code modules: It searches for the tag <module> into the pom files and in case they contain modules,
        #checks if the autogenerated section has been modified. Reading text secuence from foo.txt file
        #
        # - Exclude model folder as the codegen poms therein require such a repository



        fileArray=($(find . -type f -not -path "./folder1/*" -not -path "*/folder2/*" -not -path "./folder3/*" -name "pom.xml" \
                         | xargs `awk -v RS='^$' 'NR==FNR{str=$0;next} /<module>/ && !index($0,str){print FILENAME}' sequence {} +`))


        IFS=$OLDIFS

        # get length of an array
        numberOfFiles=${#fileArray[@]}

        # read all filenames
        for (( i=0; i<${numberOfFiles}; i++ ));
        do
          echo "ERROR:Found user code modules (file:line:occurrence): ${fileArray[$i]}"
        done


    if [ "$numberOfFiles" != "0" ]; then
        echo "SUMMARY:Found $numberOfFiles pom.xml file(s) containing user code modules."
        exit 1
    fi
}

check

---- ОБНОВЛЕНИЕ (последний вывод консоли)

    :~/temp> bash script.sh
awk: cmd. line:1: fatal: cannot open file `{}' for reading (No such file or directory)
ERROR:Found user code modules (file:line:occurrence): ./test_folder/test4/pom.xml ./tes                                                                        t_folder/test1/pom.xml ./test_folder/test2/pom.xml ./test_folder/test3/pom.xml
SUMMARY:Found 1 pom.xml file(s) containing user code modules.

Ответы на вопрос(2)

Ваш ответ на вопрос