Friday, September 26, 2008

5 searching commands in linux

1. find

2. locate
-uses a database of file location instead of searching the real location, the database only updated everyday

3. whereis [-bsm]
- returns the location for a specific command line command, -b gives the location of the binary, -s gives the location of the source, and -m gives the location of the man pages

4. which
- returns all the location for the specific command. it searches the PATH env variable for locating the binary. great if there are multiple versions of a command in PATH.
- it returns the full path for each version of the command

5. type [-a]
- returns the type of command this console is using for the default, could be a shell built in, a UNIX command, a linux command etc. -a gives this property for all commands that are with the same name

Sunday, September 14, 2008

Cloud Computing Digest

Cloud Computing is a fairly new internet service structure. it provide ways to virtually map physical storage, internet access together with a web based application for a remote user. The advantage of cloud computing is the reduction in the amount of server and energy needed to run a large scale service.
the idea of cloud computing resides in thinking of whole bunch of servers running for different services as a cloud, instead of independently running machines. It virtuallizes all physical machines into several layers: infrastructure service layer, platform service layer, and software service layer.

infrastructure service layer manages web throughput and storage space for remote server, giving each remote client a fixed network power and storage space without having all those service being tied down to one service machine. it also provide ways to run a operating platform on top of the infrastructure layer, limiting the storage and service to specific platforms that uses it.

the platform service layer provide users a selection of applications they could use. an example of platform service is the google application engine

the software service layer contains web applications the user may use, one example would be Google Apps.

information digested from here

Monday, September 8, 2008

some more UNIX tips

1. auto-complete features in all shells:

bash: TAB or double TAB
cash: escape
korn: escape \ or double escape (depends on EDITOR var setting, either vi or emacs)

2. accessing previous command arguments from shell
$! access the last argument of the last command entry
!:1 or another number can access the last command argument at the position starting from 1

3. pushd and popd creates a stack of file locations that can be accessed without using cd command. it can also manipulate the stack, rotating its order with +i or -i where i is the rotation number to rotate, + puts the frontmost to the back, - puts the backmost to the front

4. curl command can be used to retrieve web information, use -s to ignore processing output, use -o to download any file from the internet

5. name matching special characters:
^ -> matching anything to the starting of line as in ^A
? -> matching anything at the end of the line A?
[] -> matching any character within the bracket, use - for indicating range
[^]-> matching any character except for those within the bracket
. -> match a single character of any value except for EOF
* -> match 0 or more preceding characters to expression
\{x,y\} -> match to x to y occurence of the preceding
\{x\} -> match to exactly x occurence of the preceding
\{x,\} -> match to x or more occurence of the preceding

6. some awk example (more examples)

$ cat text
testing the awk command
$ awk '{ i = length($0); print i }' text
23
$ awk '{ i = index($0,”ing”); print i}' text
5
$ awk 'BEGIN { i = 1 } { n = split($0,a," "); while (i <= n) {print a[i]; i++;} }' text

(summarized from here)

Wednesday, September 3, 2008

Google Chrome, so much faster and so much more simple to use

it looks like google's new browser: Chrome is so 5 times faster than firefox and other browsers in general. it is also very small and very simple to use.

you may download it here

Thursday, August 28, 2008

another good reminder that lots of fun google search techniques are here

1. "define:" gives you the meaning of all words you write afterwards
2. "time" gives you the time of location
3. google search can be used as calculator with equation and end with '='
4. currency conversion by in
5. get the map of a city by map
6. get related search results using the "related:" keyword
7. use + and - in search term to plus a meaning or minus a meaning to the search term
8. type in a 3 digit and get the area where the 3 digit is used as phone number initial
9. quote search terms to get the exact result you want

Monday, August 25, 2008

in case i forgot it again, here is the link to wxWidgets installation guide for VC++2008

LINK

good linux habits

taken from IBM Linux help site

1. mkdir -p option allows multiple directory in different depth to be created all at once

e.g. mkdir -p good/{fun,happy/photos}
will create a directory good, which contains 2 directories fun and happy, and in happy a new directory photos

2. tar xvf -C unarchive without having to move the tar to the destination directory, giving the user an option to specify where the directory the tar will be unarchived

e.g. tar xvf /temp/a newarc.tar.gz

3. the && and || operator in command line are more advaned replacements for ;, which is the command separator in console. && checks if previous command have executed and returned 0, and only if it returned 0 the second command runs. || checks if the previous command returned non-zero, and only execute second command if non-zero return exit has been returned

e.g. cd /temp/a && mkdir b
e.g. cd /temp/a || mkdir -p /temp/a

4. It is generally a good idea to enclose variable calls in double quotation marks, unless you have a good reason not to. Similarly, if you are directly following a variable name with alphanumeric text, be sure also to enclose the variable name in curly braces ({}) to distinguish it from the surrounding text.

5. the escape sequence \ makes commands more clear

6. it's good habit to group commands using () in subshell or {} in current shell. this way all commands inside () or {} have their outputs grouped together for further use. make sure that there is a space between commands and {}

7. xargs is a powerful output format tool that can do many types of filtering

e.g. ls -l | xargs
combines all listed files into one line

e.g. ls | xargs file
lists all files and its file type

a caution that xargs can cause error when reading '_', which if placed in a single line cause xargs to ignore anything afterwards, xargs -e turns off the end of file string feature

8. grep -c does the same thing as grep | wc -l and is faster. but grep -c only count lines containing matching patterns. to count all matching patterns,even if a line contain more than 1, use grep -o | wc -l

grep -o cannot be used with -c at the same time

9. use awk instead of grep when possible. awk captures the line if word matches the key at the right index

e.g. ls -l | awk '$6 = "Dec"'
captures all lines with 6th word = Dec

10. grep doesn't have to work with cat because grep can take file names as arguments

e.g. time grep and tmp/a/longfile.txt
does the same as time cat tmp/a/longfile.txt | grep and