home · blog · groups · about us · contact us
DevelopmentNow Blog
 Saturday, May 17, 2008
 
 

I do more & more Linux work from the shell, and it's starting to grow on me. ;)

I used to search through files using this command

find . | xargs grep -s 'keyword'

but now & again get errors like xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

So I found this command works instead

find . -printf '"%p"\n' | xargs grep -s 'keyword'

or you can make a handy shell script (e.g. search.sh) like this

#!/bin/bash

find . -printf '"%p"\n' | xargs grep -s "$1"

and then search files like

search.sh 'keyword'
May 17, 2008    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [1]

Related posts:
View Apache Process Details
Slicehost and Securing SSH
Default ownership and permissions for new Linux files
Recursive FTP for Linux
Happy New Year and Joomla! 1.5 Caching
Enabling MySQL Logging


« How to Disable AVG Antivirus in Vista | Main | Hosting Tip: Be an Official Technical Co... »
Thursday, July 03, 2008 7:07:18 AM (Pacific Standard Time, UTC-08:00)
never tried :

find . -name "keyword"

or

find . -name "*keyword*"

find is full of options...
Comments are closed.