Skip to main content

Posts

Showing posts from June, 2008

Some Useful Unix commands

I find myself using the below comments day to day. Enjoy!! 1. ps 2. find 3. df 4. du ps Display memory size of the process running sorted 1. ps -e -o vsize,command,time |sort -gr |more for full command line (os x) 1. ps -ax -www |grep Java find find files that matches the filename pattern 1. find . -name "*.*" find anything of type file 1. find . -type f find anything of type directory 1. find . -type d find files (and display contents) that matches the filename pattern and matches content 1. find . -name "*.*" -exec grep 'search me' {} \; find files (and display filenames) that matches the filename pattern and matches content 1. find . -name "*.*" -exec grep -l 'search me' {} \; 2. find . -name "*.*" |xargs grep 'department' df display partition information in human readable format 1. df -h du display disk usage from the current directory in human readable format 1. du -h display disk usage

Oracle Data Tricks

Oracle is not a very friendly enviornment to deal with date types. I always find myself googling around to find a proper method to deal with date arithmetics. The below is a method I came across that helps adding and subtracting years, months, and days from a date type. Enjoy! update employee set SERVICE_DATE = add_months(SERVICE_DATE, -1200) where employee_id in (select e.EMPLOYEE_ID from INTERFACE_EXTRACT et, danaher.employee e where et.NUMBER = e.EMPLOYEE_ID and et.HIRE_DATE != e.SERVICE_DATE and to_number(to_char(e.SERVICE_DATE, 'YYYY'), '9999') > 2010) The above query for example sets the SERVICE_DATE column to be 1200 months earlier. The return value of the add_months function is of type date .