View Single Post
Old 11-12-2013, 09:04 AM   #31
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by lookout View Post
[root@[192_168_15_244] root]# cd /
[root@[192_168_15_244] /]# ls
bin cust dev etc lib mnt opt proc sbin sys tmp usr var
[root@[192_168_15_244] /]# find . -print0 | xargs -0 grep -i -n "wifi"
I do not recognize 'cust' - any idea what that is?

The directories: /dev, /proc, /sys are built dynamically at boot, no need to search those.
Plus, as twobob points out, they can (and will) have recursive entries.

Same with /mnt in the case where its entries contain the directories already mentioned - no need to search things multiple times.

Which trims your list down to: (?cust?)
bin cust etc lib opt sbin tmp usr var

With a little bit of knowledge of the LFS (google it) you could cut that done further - but that is an "advanced student topic".

Your terminal window cut&paste shows two different, unrelated, ways of finding a file.
Either a file named 'wifi' (not likely - don't even waste the cpu looking) and for a file that contains the sub-string 'wifi' - -

That second is probably what you want in this case.

The two commands:
cd /
find . <more stuff>
Tells find to start looking in the current (root) directory - at everything.

Why use find in this case? Duh.

Let grep search each top level directory you want searched recursively

Code:
for D in /bin /cust /etc /lib /opt /sbin /tmp /usr /var ; do grep -r 'wifi' $D ; done
ash is not Bash - but a sub-set -
Still, Bash is better documented: http://www.tldp.org/LDP/abs/html/

(you are welcome to ignore that I am one of the contributing authors.)
knc1 is offline   Reply With Quote