2011/06/09

Linux Command Examples

Delete a folder recursively
find . -type d -name .svn -exec rm -rf {} \;

Kernel Debug Message
dmesg -wH

Zip and unzip
tar czvf xxx.tgz folder/
tar xvzf file-1.0.tar.gz
tar xvjf file-1.0.tar.bz2
tar xvf file-1.0.tar

Get the log to a file
./some_exe 2>&1 | tee fileName.log

How to find a file by name
find /etc -name "ho*t" -print
updatedb
locate filenamefin

How to grep a string from a folder
grep -R "string string" *

Check the return value of the command
echo $?c

How to patch diff
diff -rupN original/ new/ > some.diff
patch -p0 --dry-run < some.diff
patch -p0 < some.diff
patch -p0 -R < some.diff

Version Control
create branch
svn copy http://svn.example.com/repos/calc/trunk  http://svn.example.com/repos/calc/branches/my-calc-branch  -m "Creating a private branch of /calc/trunk."

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

delete cvs
find . -name 'CVS' -type d -exec rm -rf {} \;

Device Access
sudo dd of=/dev/zero if=/dev/mtd0 skip=1 bs=512 count=1

No comments:

Post a Comment

Post Code on Blogger

Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...