KnowledgeBase

Scripting

Recursively delete directories with a given name

Windows (deletes .svn control directories):

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *svn') do (
	rd /s /q "%%i"
)

Bash

rm -rf `find . -type d -name .svn`

Merge files

Windows

copy /b file1.bin + file2.bin + file3.bin newfile.bin
copy /b *.bin newfile.bin

Find files

Unix

find /starting/directory -name "filename" -type f

Find text in files

Unix

grep -i -n 'text_to_find' *

Replace text in files

Unix/Cygwin

find . -name 'entries' -print0 | xargs -0 perl -pi -e 's/svn:\/\/i\.canco\.de/http:\/\/i\.cantco\.de/'

Write date to variable

Unix

DATE=`date +%Y_%m_%d`

Recursively count number of lines in files

find . -name "*.lua" -print0 | xargs -0 wc -l 

Generate MD5 from string

echo -n “string” | md5sum

Copy SVN files from one working copy to another

In case something screwed up again... ;-)

find . -name .svn -print0 | xargs -0 -I {} echo cp {} ~/Documents/DVW/dvw/{}

Knowledge Base

Game Development

Personal

PmWiki

pmwiki.org

edit SideBar

Page last modified on November 09, 2009, at 10:51 AM