Perl Search and Replace in files

July 6th, 2014

Replace all occurrences of “oldstring” with “newstring” in all files (no recursion):

perl -pi -e 's/oldstring/newstring/g' * 

Replace all occurrences of “oldstring” with “newstring” in all HTML files recursively:

perl -pi -e 's/oldstring/newstring/g' `find ./ -name *.html` 

Replace all occurrences of “oldstring” with “newstring” in all files recursively:

perl -pi -e 's/oldstring/newstring/g' `grep -irl oldstring *` 

Replace all occurrences of “oldstring” with “newstring” in all files recursively, excluding .svn directories:

perl -pi -e 's/oldstring/newstring/g' `grep -irl oldstring * | grep -v .svn'
 

Taken from this blog which seems to no longer be active.

CRLF to LF

July 6th, 2014

Windows uses two bytes for end-of-line markers, namely CR and LF, while Linux and Unix only use one: LF

dos2unix filename

sed -i 's/\r$//' file

perl -pi 's/\r$//' file

Source: Shell trick: CRLF to LF

Password Protect PHP Pages

July 6th, 2014

HP Slate 7

July 6th, 2014

Miscellaneous Android Info

July 6th, 2014