1. Find a string (only in alphabets)
# grep -rw "search string" ./
2. Find a string
# grep -i -l "search string" * -r 2> /dev/null
2>/dev/null : direct error outputs to /dev/null
3. Find a string(all languages can be used for search string)
# find . -exec grep -l "search string" {} \; 2>/dev/null
4. Find a string(case insensitive)
# find . -exec grep -i -l "search string" {} \; 2>/dev/null
-i: case insensitive
5. Find and replace a string
# find . -exec perl -pi -e 's/search string/replace string/g' {} \; 2>/dev/null
# find . -type f -exec sed -i 's/ugly/beautiful/g' {} \;
6. Find a file
# find / -name filename -type f
7. Find a file(case insensitive)
# find / -iname filename -type f
8. Find a directory
# find / -name filename -type d
9. Find a directory(case insensitive)
# find / -iname directoryname -type d
10. Find all files that matches to the filename
find . | xargs grep 'filename'
http://www.brunolinux.com/02-The_Terminal/Find_and%20Replace_with_Sed.html
http://apms.tistory.com/tag/replace
댓글 없음:
댓글 쓰기