$@- The file name of the target.
$%- The target member name, when the target is an archive member.
$<- The name of the first prerequisite.
$?- The names of all the prerequisites that are newer than the target, with spaces between them. For prerequisites which are archive members, only the member named is used (see Archives).
$^$+- The names of all the prerequisites, with spaces between them. For prerequisites which are archive members, only the member named is used (see Archives). The value of
$^omits duplicate prerequisites, while$+retains them and preserves their order. $*- The stem with which an implicit rule matches (see How Patterns Match).
January 16, 2008
Makefile Variables
January 8, 2008
BASH programming reference card
Appendix B. Reference Cards
The following reference cards provide a useful summary of certain scripting concepts. The foregoing text treats these matters in more depth, as well as giving usage examples.
Table B-1. Special Shell Variables
| Variable | Meaning |
|---|---|
| $0 | Filename of script |
| $1 | Positional parameter #1 |
| $2 - $9 | Positional parameters #2 - #9 |
| ${10} | Positional parameter #10 |
| $# | Number of positional parameters |
| "$*" | All the positional parameters (as a single word) * |
| "$@" | All the positional parameters (as separate strings) |
| ${#*} | Number of command line parameters passed to script |
| ${#@} | Number of command line parameters passed to script |
| $? | Return value |
| $$ | Process ID (PID) of script |
| $- | Flags passed to script (using set) |
| $_ | Last argument of previous command |
| $! | Process ID (PID) of last job run in background |
* Must be quoted, otherwise it defaults to "$@".
Table B-2. TEST Operators: Binary Comparison
| Operator | Meaning | ----- | Operator | Meaning |
|---|---|---|---|---|
| Arithmetic Comparison | String Comparison | |||
| -eq | Equal to | = | Equal to | |
| == | Equal to | |||
| -ne | Not equal to | != | Not equal to | |
| -lt | Less than | \< | Less than (ASCII) * | |
| -le | Less than or equal to | |||
| -gt | Greater than | \> | Greater than (ASCII) * | |
| -ge | Greater than or equal to | |||
| -z | String is empty | |||
| -n | String is not empty | |||
| Arithmetic Comparison | within double parentheses (( ... )) | |||
| > | Greater than | |||
| >= | Greater than or equal to | |||
| < | Less than | |||
| <= | Less than or equal to |
* If within a double-bracket [[ ... ]] test construct, then no escape \ is needed.
Table B-3. TEST Operators: Files
| Operator | Tests Whether | ----- | Operator | Tests Whether |
|---|---|---|---|---|
| -e | File exists | -s | File is not zero size | |
| -f | File is a regular file | |||
| -d | File is a directory | -r | File has read permission | |
| -h | File is a symbolic link | -w | File has write permission | |
| -L | File is a symbolic link | -x | File has execute permission | |
| -b | File is a block device | |||
| -c | File is a character device | -g | sgid flag set | |
| -p | File is a pipe | -u | suid flag set | |
| -S | File is a socket | -k | "sticky bit" set | |
| -t | File is associated with a terminal | |||
| -N | File modified since it was last read | F1 -nt F2 | File F1 is newer than F2 * | |
| -O | You own the file | F1 -ot F2 | File F1 is older than F2 * | |
| -G | Group id of file same as yours | F1 -ef F2 | Files F1 and F2 are hard links to the same file * | |
| ! | "NOT" (reverses sense of above tests) |
* Binary operator (requires two operands).
Table B-4. Parameter Substitution and Expansion
| Expression | Meaning |
|---|---|
| ${var} | Value of var, same as $var |
| ${var-DEFAULT} | If var not set, evaluate expression as $DEFAULT * |
| ${var:-DEFAULT} | If var not set or is empty, evaluate expression as $DEFAULT * |
| ${var=DEFAULT} | If var not set, evaluate expression as $DEFAULT * |
| ${var:=DEFAULT} | If var not set, evaluate expression as $DEFAULT * |
| ${var+OTHER} | If var set, evaluate expression as $OTHER, otherwise as null string |
| ${var:+OTHER} | If var set, evaluate expression as $OTHER, otherwise as null string |
| ${var?ERR_MSG} | If var not set, print $ERR_MSG * |
| ${var:?ERR_MSG} | If var not set, print $ERR_MSG * |
| ${!varprefix*} | Matches all previously declared variables beginning with varprefix |
| ${!varprefix@} | Matches all previously declared variables beginning with varprefix |
* Of course if var is set, evaluate the expression as $var.
Table B-5. String Operations
| Expression | Meaning |
|---|---|
| ${#string} | Length of $string |
| ${string:position} | Extract substring from $string at $position |
| ${string:position:length} | Extract $length characters substring from $string at $position |
| ${string#substring} | Strip shortest match of $substring from front of $string |
| ${string##substring} | Strip longest match of $substring from front of $string |
| ${string%substring} | Strip shortest match of $substring from back of $string |
| ${string%%substring} | Strip longest match of $substring from back of $string |
| ${string/substring/replacement} | Replace first match of $substring with $replacement |
| ${string//substring/replacement} | Replace all matches of $substring with $replacement |
| ${string/#substring/replacement} | If $substring matches front end of $string, substitute $replacement for $substring |
| ${string/%substring/replacement} | If $substring matches back end of $string, substitute $replacement for $substring |
| expr match "$string" '$substring' | Length of matching $substring* at beginning of $string |
| expr "$string" : '$substring' | Length of matching $substring* at beginning of $string |
| expr index "$string" $substring | Numerical position in $string of first character in $substring that matches |
| expr substr $string $position $length | Extract $length characters from $string starting at $position |
| expr match "$string" '\($substring\)' | Extract $substring* at beginning of $string |
| expr "$string" : '\($substring\)' | Extract $substring* at beginning of $string |
| expr match "$string" '.*\($substring\)' | Extract $substring* at end of $string |
| expr "$string" : '.*\($substring\)' | Extract $substring* at end of $string |
* Where $substring is a regular expression.
Table B-6. Miscellaneous Constructs
| Expression | Interpretation |
|---|---|
| Brackets | |
| if [ CONDITION ] | Test construct |
| if [[ CONDITION ]] | Extended test construct |
| Array[1]=element1 | Array initialization |
| [a-z] | Range of characters within a Regular Expression |
| Curly Brackets | |
| ${variable} | Parameter substitution |
| ${!variable} | Indirect variable reference |
| { command1; command2; . . . commandN; } | Block of code |
| {string1,string2,string3,...} | Brace expansion |
| {a..z} | Extended brace expansion |
| {} | Text replacement, after find and xargs |
| Parentheses | |
| ( command1; command2 ) | Command group executed within a subshell |
| Array=(element1 element2 element3) | Array initialization |
| result=$(COMMAND) | Execute command in subshell and assign result to variable |
| >(COMMAND) | Process substitution |
| <(COMMAND) | Process substitution |
| Double Parentheses | |
| (( var = 78 )) | Integer arithmetic |
| var=$(( 20 + 5 )) | Integer arithmetic, with variable assignment |
| (( var++ )) | C-style variable increment |
| (( var-- )) | C-style variable decrement |
| (( var0 = var1<98?9:21> | C-style trinary operation |
| Quoting | |
| "$variable" | "Weak" quoting |
| 'string' | "Strong" quoting |
| Back Quotes | |
| result=`COMMAND` | Execute command in subshell and assign result to variable |
November 11, 2007
Change Auotplay for DV Camera
use regedit, goto HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\EventHandlers,
you will see an entry: VideoCameraArrival, with a key "MSVideoCameraArrival" with no value. This handler is defined in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers.
So all I needed to do is to add a key "MyVideoHandler" to the key VideoCameraArrival, next to MSVideoCameraArrival, then define MyVideoHandler in 'Handlers', with the contents of:
Action: "YOUR PROGRAM PATH"
initCmdLine: "YOUR PROGRAM PATH"
ProgID: Shell.HWEventHandlerShellExecute
That did the trick. Now when I plug in my DV, windows asks me which handler to use. I can pick either.
September 18, 2007
September 1, 2007
My Cat JiaoJiao Died Today
A day to grieve.
Little JiaoJiao died today. She lied still in the street of our neighborhood. It looks like she was run over by a car during the night.
She has been a very sweet cat. Never scratched people. Never bitted people. She has very software hairs. She was as sweet as a cat can be. My wife used to cut her nails and bathe her without any complaints from her.
When we moved from Maryland to California, we had to leave one of our two cats behind. The other cat, Mimi, was adopted by a colleague of mine. We took JiaoJiao with us on the plane.
She is an indoor-converted-outdoor cat. She is very curious and likes to roam around, but she never jumped fence or anything like that. She simply walks around, lies down on sidewalk or under the bush.
Recently she became a little bold and not afraid of cars, which eventually killed her. For several times we had to take her away from the driveway so that we can park our cars.
We buried little JiaoJiao in the garden of our side yard.
She has been a happy member of our family for the past 5 years. She will live in our memories.
Go in peace, little JiaoJiao!
-- The family
August 23, 2007
Isaac Milestone: Turns
Live Support Chat for your website
This guy also wrote some test code but it does not seem to function
http://www.boutell.com/newfaq/creating/support.html
August 13, 2007
Find best childcare in your area
Their toll free number is 1-800-424-2246
August 11, 2007
Free and Legal Music
2. http://www.goingware.com/tips/legal-downloads.html#websites
3. Search Engine http://search.creativecommons.org/#
4. http://www.piano-midi.de/chopin.htm
Cheap OKI C5150n Cartridge
Not tried it yet. Looks good.
Cheap ML 1710 Laser Toner at
http://www.tonerkits.com/ml1710-3.html#
VCD authoring tools and related
2. ISO Recorder (http://isorecorder.alexfeinman.com/isorecorder.htm)
3. GNU vcdimager
4. VCDGear (convert mpeg1/2 to bin/cue file and back) at (http://www.vcdgear.com/download.html)
August 8, 2007
How to copy table from Firefox to Excel
Step 1: Hold down the CTRL key and click just outside the boarder of your grid. Either just above the grid, or on one of the sides. The entire grid should become highlighted.
Step 2: CTRL+C
Step 3: Open Excel and hit CTRL+V. You should get the entire grid pasted and formatted the same way you see it in Firefox.
Here is a good URL to practice with http://www.w3schools.com/browsers/browsers_stats.asp
To Paste a subset of a table, you will need to paste one column at a time:
Step 1: Ctrl+drag over the column you want in Firefox (yes, 1 column at a time).
Step 2: Paste into Excel. It will paste as a row, not a column. Don't worry - we'll get back to this. Repeat Steps 1 & 2 for as many cols of data that you need.
Step 3: After you have all the data you need into Excel (in rows), select them all and copy. Now move a few cells down and choose "Paste Special" - you'll see a few new options now. Choose "Transpose" in that dialog. This will turn the rows into columns.
July 26, 2007
July 19, 2007
Eating Place
Z-Pizza: Los Alamitos & 405
macaroni grill: Los Alamitos & 405
美食林: Alondra, 牛肉饼,木须肉
大肚鱼:South & Pinoeer
July 17, 2007
vim multiple repeat command
Or simpler:
:g/PATTERN/-1d
or even more simpler
:g/PATTERN/d
can be used to delete all lines that match PATTERN
See help :g for more
Another post from VIM TIP #227
:v/./,/./-j
I'll break down this incredible collapse-multiple-blank-lines command for everyone, now that I finally figured out how it works.
First, however, I'll rewrite it this way to illustrate that some of those slashes have totally different meaning than others:
:v_._,/./-1join
Note that to delimit expressions like these, just about any symbol can be used in place of the typical slashes... in this case, I used underscores. What we have is an inverse search (:v, same as :g!) for a dot ('.') which means anything except a newline. So this will match empty lines and proceed to execute [command] on each of them.
:v_._[command]
The remaining [command] is this, which is a fancy join command, abbreviated earlier as just 'j'.
,/./-1join
The comma tells it to work with a range of lines:
:help :,
With nothing before the comma, the range begins at the cursor, which is where that first blank line was. The end of the range is specified by a search, which to my knowledge actually does require slashes. The slash and dot mean to search for anything (again), which matches the nearest non-empty line and offsets by {offset} lines.
/./{offset}
The {offset} here is -1, meaning one line above. In the original command we just saw a minus sign, to which vim assumes a count of 1 by default, so it did the same thing as how I've rewritten it, but simply with one character fewer to type.
/./-1
There is a caveat about join that makes this trick possible. If you specify a range of only one line to "join", it will do nothing. For example, this command tells vim to join into one line all lines from 5 to 5, which does nothing:
:5,5join
In this case, any time you have more than one empty line (the case of interest), the join will see a range greater than one and join them together. For all single empty lines, join will leave it alone.
There's no good way use a delete command with :v/./ because you have to delete one line for every empty line you find. Join turned out to be the answer.
This command only merges truly "empty" lines... if any lines contain spaces and/or tabs, they will not be collapsed. To make sure you kill those lines, try this:
:v/^[^ \t]\+$/,/^[^ \t]\+$/-j
Or, to just clean such lines up first,
:%s/^[ \t]\+$//g
July 3, 2007
Air Ticket Agent
| 纳美旅行社 (Oriental Tour & Travel) | 800-951-3391 866-783-1688 |
| Bravo travel | 1-626-280-9988 |
| 中旅国际洛杉矶 (China Travel Service LA Office) | 888-664-5678 626-576-9688 |
| 美国亚洲旅行社 | 626-350-6376 |
泉威旅行Champion Travel Service (626)854-1808
| 一帆国际旅游 ( Vanguard Int'l Travel) | 866-882-6888 718-886-8868 |
| 加州阳光 | 626-5882818 |
| 丽来 | 1-909-594-6899 |
| JNC | 626-573-8888 |
| polo tours | 800-822-7656 |
| J&C Travel, Inc. | 626-573-8888 |
| 捷胜国际旅游 ( Sunlight International Travel) | 866-838-6898 718-762-1800 |
| 来来 | 213-626-6118 |
| 蓝天 | 800-644-3615 |
Software
PDFTK: free PDF tools
PDFTK GUI: http://angusj.com/pdftkb/
PDF Viewer with comment capability: http://www.docu-track.com/home/prod_user/pdfx_viewer/
May 15, 2007
snmptrap command
syntax:
-v 1: version 1
-c public: use community string "public"
192.168.100.40: trap manager's IP address (trap destination)
1.2.3.4: enterprise (i.e. type of device/object generating trap, default to system ID in mib II, can be empty)
192.168.254.50: trap source IP address (device's IP address)
3: generic trap ID, they are:
- coldStart(0),
- warmStart(1),
- linkDown(2),
- linkUp(3),
- authenticationFailure(4),
- egpNeighborLoss(5),
- enterpriseSpecific(6)
0: specific trap ID, 0 when generic trap ID is not 6
'': system up time (timestamp)
You can also add "mib type value" to the end of the command to send them along with the trap
v2 trap:
snmptrap -v 2c -c public 192.168.100.40 "" 1.2.3.4.0
"": system Uptime (when given as empty "", the system finds itself)
1.2.3.4.0: trap OID
again, add "mib type value" to the end if you want.
v3 trap:
snmptrap -v 3 -a SHA -A 1234567890 -x DES -X 1234567890 -l authPriv -u myuser -e "123abc" 192.168.100.1 "" linkUp.0
---
Update (09/10/2013)
When running snmptrap command, and seeing warning message like:
read_config_store open failure on /var/lib/net-snmp/snmpapp.conf
is okay. The trap is still being sent.
To run a debug catch-all snmptrapd:
snmptrapd -Le -On -f -n
with the following just-one-line in /etc/snmp/snmptrapd.conf
disableAuthorization yes
-n: no DNS lookup
-f: no fork
-On: print numeric OID
-Le: log to standard error
April 27, 2007
Some Useful Links for Linux
http://www.debian.org/distrib/packages
SSH X11 forwarding details
http://www.hackinglinuxexposed.com/articles/20040705.html
