Saturday, December 20, 2008

Using locate and updatedb in Cygwin

updatedb --prunepaths='/proc /cygdrive/[^/]*'
locate 'filename'

Sunday, December 7, 2008

Why is my variable disappearing in my script?

It took me a while to figure this out. Sometimes my variable's value did not show up in my script in the following scenarios. It turned out I have a trailing underscore after it, like this:
export VAR1="Hello"
export VAR2="World"

# WRONG: Interpreted as $VAR1_
echo "Create a file called $VAR1_$VAR2.log"

# CORRECT: Use quotes or brackets
echo "Create a file called ${VAR1}_${VAR2}.log"
echo "Create a file called "$VAR1"_"$VAR2".log"

Monday, November 10, 2008

Linux Tasks and Processes

To list Process Status (ps):
$ ps -ef     # --everyone, --full
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 Nov01 ?        00:00:00 init [3]
root         2     1  0 Nov01 ?        00:00:00 [migration/0]
root         3     1  0 Nov01 ?        00:00:00 [ksoftirqd/0]

$ ps -al     # --all (same as -e), --long
      PID    PPID    PGID     WINPID  TTY  UID    STIME COMMAND
     4516       1    4516       4516    ? 117771   Nov  4 /usr/bin/mintty
     5280    4516    5280       4412    2 117771   Nov  4 /usr/bin/bash
     5444    5280    5444        456    2 117771   Nov  4 /usr/bin/ssh
     6480       1    6480       6480    ? 117771   Nov  8 /usr/bin/mintty