Wednesday, July 11, 2007

UNIX - find cheet sheet

Find all files named "foo" in directory "/" recursively
find / -name foo

Find all files named "foo" in directory "/"
find / -maxdepth 1 -name foo

Find all files name "foo" in current directory descending recursively
find . -name foo

Find all files starting with "foo" and ending with "bar" in the current directory
find . -name foo*bar
find . -name "foo*bar"

Find all files modified in the last seven days and tar them
find / -type f -mtime -7 | xargs tar -rf weekly_incremental.tar

Find all files named core and delete them
find / -name core | xargs /bin/rm -f
find / -name core -exec '/bin/rm -f {} ;'

Locate files modified less than 10 minutes ago
find / -mmin -10

locate files that are writeable by "others"
find . -perm +o=w

Locate files owned by a user
find . -name core -user ssinghal

Find mtime and mmin options
When specifying time with find options such as -mmin (minutes) or -mtime (24 hour periods, starting from now), you can specify a number "n" to mean exactly n, "-n" to mean less than n, and "+n" to mean more than n.
find . -mtime 0 # find files modified within the past 24 hours
find . -mtime -1 # find files modified within the past 24 hours
find . -mtime 1 # find files modified between 24 and 48 hours ago
find . -mtime +1 # find files modified more than 48 hours ago
find . -mmin +5 -mmin -10 # find files modifed between 6 and 9 minutes ago

Tuesday, July 10, 2007

moving around in bash

when you are in bash , do as emacs does.

The default orientation of bash command line is emacs. And though I am a big vim fan, I have gotten used to emacs mode for command line. And as they say, old habits die hard!

Here are some shortcuts to help you move around on the command line .


  • ctrl + e : takes you to the end of a command

  • ctrl + a : takes you to the beginning of a command

  • esc + f : takes you one word forward

  • esc + b : takes you one word backward

  • esc + d : deletes a word and puts it in a buffer

  • crtl + k : deletes the line from current word and puts it in a buffer

  • ctrl + y : paste contents of buffer

Vim and Sqlplus

open the following file :
$ORACLE_HOME/sqlplus/admin/glogin.sql
Add following line :
DEFINE _EDITOR='gvim -c "set filetype=sql"'

Typing edit will now open your favorite editor