Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm finding that a script is getting started twice, so I want to search for the script name in any file anywhere, to see where its getting called.

So I did this...

cd /
sudo grep -r autostart *

But that gives me the error..

boot/System.map-3.5.0-23-generic:c1490f90 t autostart_arrays
grep: dev/vsock: Invalid argument
share|improve this question
    
sudo grep -rl autostart /*. Does that work? –  andy Sep 26 '13 at 14:52

1 Answer 1

This is not an error. Grep just reported its failure to search through a special file (probably a socket), and was already working on the next. If you don't want to see grep's error messages, you can send them to the bitbucket:

fgrep -r autostart * 2> /dev/null

Note that fgrep will likely be much faster in your case because you are searching for a string, not for a regular expression.

Contrary to what you it looked like, grep hadn't crashed. Technically, it wasn't hung either. Maybe it was searching /dev/random for the string. Eventually it would find it there, though this might take an astronomical amount of time. Sadly, soon after grep would have found the string in /dev/random, it would encounter /dev/zero where it would certainly spend an infinity of time looking for the string. Logically therefore, your command was guaranteed to not terminate.

If you wish to prevent fgrep from searching special files, combine it with find:

find / -type f -exec fgrep -l autostart {} \;

And since you're looking for a script, skipping all all non-executables on the file system will save a lot of time:

find / -type f -executable -exec fgrep -l autostart {} \;

In fact, I would focus my search first on the usual suspects:

find {,/usr}/{,s}bin /etc -type f -executable -exec fgrep -l autostart {} \;

Particularly so if you have some remote file systems mounted, which grep would dutifully search as well.

share|improve this answer
    
Thanks. Are you saying that it hadnt crashed but had just printed out a message and was continuing to search in the background? –  spiderplant0 Sep 26 '13 at 15:22
    
Thanks, I tried find / -type x -exec fgrep -l autostart {} \; but it came back with find: Unknown argument to -type: x –  spiderplant0 Sep 26 '13 at 15:23
    
also should I add sudo before these commands? –  spiderplant0 Sep 26 '13 at 15:32
    
No, grep didn't technically crash. It was guaranteed to run forever though. Added the explanation for this to the answer. You should need to sudo these commands only if the string could be in a non-world-readable (and therefore non-world-executable) file. –  zwets Sep 26 '13 at 20:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.