I want to search for all the xml files on the server that have "Status" in them. Is this the correct code that I should use? Can anyone explain exactually what this code does?
It searches for all XML files in the current directory hierarchy (find . -name "*.xml") for the string Status (-exec grep -l ".Status") (the . in this search pattern is superfluous), returning the names of the files (grep -l) that do into a variable called xmlFileNames (xmlFileNames=$(...)).
for xmlFileName in ${xmlFileNames}
do
xmlFileName=$(echo $xmlFileName | sed 's|./||') # Remove leading ./ path that find command prefixes to filenames
cp -f $xmlFileName $DIR/$xmlFileName
done
I'm not using the find command anymore just the grep. Would that create a problem with the echo command?
---------- Post updated at 08:42 AM ---------- Previous update was at 08:07 AM ----------
Every time I run this script that I'm creating I keep getting this error:
filename.ksh 89:no memory : Not enough storage is available to process this command.
I assume its the line with the echo & sed commands that are causing the problem. Its only less than 1000 xmls files that I'm trying to copy. They're not even large files. Idk?
I'm not sure what the syntax for the read command should be translated from this code
for XmlFileName in ${xmlFileNames}
do
XmlFileName=$(echo $XmlFileName | sed 's|./||') # Remove leading ./ path that find command prefixes to filenames
cp $PXmlFileName $NEW_DIR/
done