Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Carlo

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Multiple File Search and Replace

   1  perl -pi -w -e 's/search/replace/g;' *.txt


Bear in mind what's between the single quotes after the -e option is a line of Perl code and the search argument is a regular expression, so some characters will have special meanings. You can escape special characters (like the forward-slash, dot, caret, dollar sign, and so on) by preceeding them with a back-slash.

Find Files Containing Text

Find files that contain a text string:

   1  grep -lir "some text" *


The -l switch outputs only the names of files in which the text occurs (instead of each line containing the text), the -i switch ignores the case, and the -r descends into subdirectories.
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS