Can I speed up my grep command?

Chubler_XL already proposed a solution to overcome that problem.

I just need to get the server back working again! The old grep command I used at least worked then....

---------- Post updated at 07:41 AM ---------- Previous update was at 07:36 AM ----------

Windows NT

---------- Post updated at 07:44 AM ---------- Previous update was at 07:41 AM ----------

I ran the find part of the statement & it work. Then I ran the grep part & it still works. But it won't work together as it use to run! I don't understand!

---------- Post updated at 07:45 AM ---------- Previous update was at 07:44 AM ----------

It keeps coming back with no data. But when I do an

ls or grep -l "Status" *.xml 

They're there! I'm confused! Help! lol Please?

We don't know what your server problems are. If it stopped working, that will definitely not be due to those commands.
Or is it just your terminal session that hangs? Try <CTRL>C or <CTRL>D or kill it fromthe task manager.

Please explain in detail and plain English what your problems are, also supplying input and desired output samples.

I've only got today to get it running like it use too!

---------- Post updated at 08:01 AM ---------- Previous update was at 07:50 AM ----------

Ok when I changed my find . -name "*.xml" -exec grep -l "Status" {} \; to

uname -a
xmlFileNames=$(find . -name "*.xml" -exec grep -Fl "Status" {} '+')
printf "find w/ grep -F exit code: %d\n" $?
xmlFileNames=$(find . -name "*.xml" -exec fgrep -l "Status" {} '+')
printf "find w/ fgrep exit code: %d\n" $?

I got this error message.

find: non-terminated '-exec' argument list
Usage: find directory ... expression
find w/ grep -F exit code:2 
find: non-terminated "-exec' argument list
Usuage: find directory ... expression
find w/ fgrep exit code: 2

And now ever since then I haven't been able to run my script or the earlier find command from the command line. I don't know what to do...

---------- Post updated at 08:05 AM ---------- Previous update was at 08:01 AM ----------

I tried

which find

Because I thought maybe it was pointing at the wrong file for the find command. But It's pointing at the mks tool kit...I've triple checked my syntax over. And that's not it. Plus the script use to run. Yeah it took a while but it ran. Now it runs but can't find any of the files. I did an

ls

&

grep -l "status" *.xml

right after the script came back with no data. And the files are right there.

---------- Post updated at 08:19 AM ---------- Previous update was at 08:05 AM ----------

Somebody please help me? I have learned a valuable lesson from all of this! Learn my commands before using them!

---------- Post updated at 08:37 AM ---------- Previous update was at 08:19 AM ----------

Well, I've restarted the server & still the same problem!

OK, calm down.
Does the modification date of your .xml files indicate they've been overwritten lately?
Use an editor to open one of the .xml file and look if there's "status" in one of the eight first lines. Then use grep status on that .xml file. Report back.

Yes the status is in the first line of the xml files.

---------- Post updated at 09:05 AM ---------- Previous update was at 09:04 AM ----------

And the grep did work from the command line.

OK. What's the problem now?

The find part works too from the command line. The just wont work when I put them together.

xmlFileNames=$(find . -name "*.xml" -exec grep -l "Status" {} \; 2>/dev/null)

IDK why? I even took off the /dev/null/ part...

Your "Status" is upper case as opposed to lower in post#24.
Try to run the command without assigning the result to a variable.

The find command from the command line won't work with any other command when you use

find ...  -exec any command

This is what I get for above command:

find . -name file\* -exec grep -l 105 {} \;
./file

, so I don't think what you say is correct.

It didn't work. That's the message on the screen afterwards.

find: must specify option after -exec
Usage: find directory ... expression

Why don't you post command AND error message?

What does your find man page say?

Of course mine used to work also! This is the exact code that I put into the command line & get the error message.

find . -name "*.xml" -exec grep -l "Status" {} \;

My syntax is right! I don't understand what's wrong!

OK, try this

find . -name "*.xml" -ls

and

 find . -name "*.xml" -exec ls -la {} \;

I've got to watch what I post. I work in a sensitive environment. It even takes awhile for the find from the command line to return like it's processing! When it's done I will paste in here from the screen what I can. Should be able to put everything in but the path.

---------- Post updated at 10:00 AM ---------- Previous update was at 09:58 AM ----------

Ok I am trying those two... Thanks a lot!

---------- Post updated at 10:02 AM ---------- Previous update was at 10:00 AM ----------

First one list every file.And so did the second one! My find command did create an error. It just didn't show me any data! Wow! I'm so lost now!

It's not easy to analyse what you say. So - find -exec ls -la {} \; did succeed; it listed the relevant files. Now try

find . -name "ONE.xml" -exec ls -la {} \; -exec grep -l "status" {} \;

give it ONE single file name to find. It should ls -la that file and grep that file.

My script is suppose to get the files then copy the xml files but the variable is coming up " " and on the screen from the command line it's just returning with no data for the find combo. But I can see the data & there's the "Status" in all of the ones that I need. Could the output maybe going in some strange place? I look at the time stamp on the files and they say modified at the time that I run my script. No files are moved to the directory.

---------- Post updated at 10:20 AM ---------- Previous update was at 10:16 AM ----------

Screen output:

D:/home/dv/daa/pt/ae(97) find . -name "*.xml" -exec grep -l "Status" {} \; 2>/dev/null
D:/home/dv/daa/pt/ae(99)

There should be over 13,000 files...

---------- Post updated at 10:22 AM ---------- Previous update was at 10:20 AM ----------

I'm going to try it without the /dev/null/ maybe I can see an error message again...

Sorry, I don't quite get what you are saying. You are always talking generically, no data, no details. How then do you expect somebody to help you?
What variable? What script? What environment? Which files/directories? Come up with real data: OS version, command versions, (partial) directory listing, (relevant) script snippet, (partial) file listings, execution logs, error messages.

You're code worked! How or why did it?

D:/home/dv/daa/pt/ae(103) find . -name "aac*.xml" -exec ls -la {} \; -exec grep -l "status" {} \;
-rwxrwxrwa   1 SERVER\user.name xyz\Domain+Users    1400 Oct  8 09:33 ./aac-27.xml