Shellscript Tricks
RGB Color Table
Red
|
Green
|
Blue
|
Color
|
0
|
0
|
0
|
black
|
1
|
1
|
1
|
white
|
1
|
0
|
0
|
red
|
0
|
1
|
0
|
green
|
0
|
0
|
1
|
blue
|
1
|
1
|
0
|
yellow
|
1
|
0
|
1
|
magenta
|
0
|
1
|
1
|
cyan
|
0.5
|
0.5
|
0.5
|
gray
|
0.5
|
0
|
0
|
dark red
|
1
|
0.62
|
0.40
|
copper
|
0.49
|
1
|
0.83
|
aquamarine
|
C Shell foreach
foreach event (figure5*.eps)
epstopdf $event
end
Note: process a bounch of files with the same pattern.
AWK subset
cat SHLK_2.loc | awk '$NF>3.0' > SHLK_3.loc
Note: subset a data ascii file with the last column larger than 3.0.
SED Tricks
sed 's/[_a-zA-Z.]/ /g'
Note: replace any letter inside "[ ]" with space.
Vi: Search and Replace
Vi: Search and Replace
Search (Wraped around at end of file):
Search STRING forward : / STRING.
Search STRING backward: ? STRING.
Repeat search: n
Repeat search in opposite direction: N (SHIFT-n)
Replace: Same as with sed, Replace OLD with NEW:
First occurrence on current line: :s/OLD/NEW
Globally (all) on current line: :s/OLD/NEW/g
Between two lines #,#: :#,#s/OLD/NEW/g
Every occurrence in file: :%s/OLD/NEW/g
Last modified on Feb 25, 2009