Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to find this string:

7z a -p

I've tried:

grep -iR "7z a -p" /

But it seems to hang after a while, with lots of:

grep: /sys/class/vc/vcs5/power/autosuspend_delay_ms: Input/output error
grep: warning: /sys/class/vc/vcsa5/subsystem: recursive directory loop
grep: /sys/class/vc/vcsa5/power/autosuspend_delay_ms: Input/output error
grep: warning: /sys/class/vc/vcs6/subsystem: recursive directory loop

EDIT - However, this seems to just look at static text files. In addition, what about runtime areas, memory and processes? ie the entire system? eg for mysql:

ps aux | grep "mysql -u user -p"

shows :

38164  4292 pts/0    S+   13:16   0:00 mysql -uodbcuser -px xxxxxxxx

Interestingly ps aux does hide the password with xxxxx. I can try with 7zip but it's quite fast, it has to be running at the same time as you run the ps aux command to "catch it.

share|improve this question
    
What are you trying to do? –  Michael Hampton Jun 10 '13 at 10:22
    
Trying to guarantee that the "7z a -p$password" is not stored on the server. Hence I need to demonstrate some tests that show this. –  user127379 Jun 10 '13 at 12:14
add comment

3 Answers

You should exclude directories like /sys/, /proc/ and /dev/ from your command:

grep -iR --exclude-dir='/sys' --exclude-dir='/proc' --exclude-dir='/dev' "7z a -p" / 
share|improve this answer
    
Thanks, what about runtime processes/memory? –  user127379 Jun 10 '13 at 12:24
add comment

Presumably, that string is in a script file. You might try ack (aka ack-grep).

It will automatically select only script and source files, but you can have it search all files with the -a option (in version 1). In version 2, all non-binary files are searched by default.

You can specify directories to ignore or for the search to focus on or ignore particular file types.

--[no]ignore-dir=name
--[no]elisp        .el
--[no]erlang       .erl .hrl
--[no]fortran      .f .f77 .f90 .f95 .f03 .for .ftn .fpp
for a few examples

There are many options that are the same as those of GNU grep so they will be familiar.

The builtin filtering system is very powerful and configurable. Because of the filtering, searches can be significantly faster than those using grep.

Installation couldn't be simpler.

documentation

share|improve this answer
    
Hi Dennis, Please check the update to the question. I hope you can answer it, thanks in advance! –  user127379 Jun 12 '13 at 9:42
add comment

You could throe away errors with

grep -iR "7z a -p" / 2>/dev/null

share|improve this answer
add comment

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.