Thursday, November 25, 2010

Using Lame in Cygwin to convert mp3s recursively

for ddnm in *
do
cd "$ddnm"
echo "$ddnm"
for mp3file in *.mp3
do
mp3file24="$mp3file".24
if [[ ! -f "$mp3file24" ]]
then
/cygdrive/c/lame/lame.exe -m j -b 24 --resample 11.025 -q 0 "$mp3file" "$mp3file24"
fi
done
cd ..
done

MIME types

.ai - application/postscript
.aif - audio/x-aiff
.aifc - audio/x-aiff
.aiff - audio/x-aiff
.asc - text/plain
.au - audio/basic
.avi - video/x-msvideo
.bcpio - application/x-bcpio
.bin - application/octet-stream
.c - text/plain
.cc - text/plain
.ccad - application/clariscad
.cdf - application/x-netcdf
.class - application/octet-stream
.cpio - application/x-cpio
.class - application/octet-stream
.cpio - application/x-cpio
.cpt - application/mac-compactpro
.csh - application/x-csh
.css - text/css
.dcr - application/x-director
.dir - application/x-director
.dms - application/octet-stream
.doc - application/msword
.drw - application/drafting
.dvi - application/x-dvi
.dwg - application/acad
.dxf - application/dxf
.dxr - application/x-director
.eps - application/postscript
.etx - text/x-setext
.exe - application/octet-stream
.ez - application/andrew-inset
.f - text/plain
.f90 - text/plain
.fli - video/x-fli
.gif - image/gif
.gtar - application/x-gtar
.gz - application/x-gzip
.h - text/plain
.hdf - application/x-hdf
.hh - text/plain
.hqx - application/mac-binhex40
.htm - text/html
.html - text/html
.ice - x-conference/x-cooltalk
.ief - image/ief
.iges - model/iges
.igs - model/iges
.ips - application/x-ipscript
.ipx - application/x-ipix
.jpe - image/jpeg
.jpeg - image/jpeg
.jpg - image/jpeg
.js - application/x-javascript
.kar - audio/midi
.latex - application/x-latex
.lha - application/octet-stream
.lsp - application/x-lisp
.lzh - application/octet-stream
.m - text/plain
.man - application/x-troff-man
.me - application/x-troff-me
.mesh - model/mesh
.mid - audio/midi
.midi - audio/midi
.mif - application/vnd.mif
.mime - www/mime
.mov - video/quicktime
.movie - video/x-sgi-movie
.mp2 - audio/mpeg
.mp3 - audio/mpeg
.mpe - video/mpeg
.mpeg - video/mpeg
.mpg - video/mpeg
.mpga - audio/mpeg
.ms - application/x-troff-ms
.msh - model/mesh
.nc - application/x-netcdf
.oda - application/oda
.pbm - image/x-portable-bitmap
.pdb - chemical/x-pdb
.pdf - application/pdf
.pgm - image/x-portable-graymap
.pgn - application/x-chess-pgn
.png - image/png
.pnm - image/x-portable-anymap
.pot - application/mspowerpoint
.ppm - image/x-portable-pixmap
.pps - application/mspowerpoint
.ppt - application/mspowerpoint
.ppz - application/mspowerpoint
.pre - application/x-freelance
.prt - application/pro_eng
.ps - application/postscript
.qt - video/quicktime
.ra - audio/x-realaudio
.ram - audio/x-pn-realaudio
.ras - image/cmu-raster
.rgb - image/x-rgb
.rm - audio/x-pn-realaudio
.roff - application/x-troff
.rpm - audio/x-pn-realaudio-plugin
.rtf - text/rtf
.rtx - text/richtext
.scm - application/x-lotusscreencam
.set - application/set
.sgm - text/sgml
.sgml - text/sgml
.sh - application/x-sh
.shar - application/x-shar
.silo - model/mesh
.sit - application/x-stuffit
.skd - application/x-koan
.skm - application/x-koan
.skp - application/x-koan
.skt - application/x-koan
.smi - application/smil
.smil - application/smil
.snd - audio/basic
.sol - application/solids
.spl - application/x-futuresplash
.src - application/x-wais-source
.step - application/STEP
.stl - application/SLA
.stp - application/STEP
.sv4cpio - application/x-sv4cpio
.sv4crc - application/x-sv4crc
.swf - application/x-shockwave-flash
.t - application/x-troff
.tar - application/x-tar
.tcl - application/x-tcl
.tex - application/x-tex
.texi - application/x-texinfo
.texinfo - application/x-texinfo
.tif - image/tiff
.tiff - image/tiff
.tr - application/x-troff
.tsi - audio/TSP-audio
.tsp - application/dsptype
.tsv - text/tab-separated-values
.txt - text/plain
.unv - application/i-deas
.ustar - application/x-ustar
.vcd - application/x-cdlink
.vda - application/vda
.viv - video/vnd.vivo
.vivo - video/vnd.vivo
.vrml - model/vrml
.wav - audio/x-wav
.wrl - model/vrml
.xbm - image/x-xbitmap
.xlc - application/vnd.ms-excel
.xll - application/vnd.ms-excel
.xlm - application/vnd.ms-excel
.xls - application/vnd.ms-excel
.xlw - application/vnd.ms-excel
.xml - text/xml
.xpm - image/x-xpixmap
.xwd - image/x-xwindowdump
.xyz - chemical/x-pdb
.zip - application/zip

Disabling right click on whole html

Disabling right click on whole html
===================================
<body oncontextmenu="return false">

Disabling right click on whereever reqd
=======================================
<tr oncontextmenu="return false">

Perl One Liners

Just enough perl to do most everything! Tom Christianson (spelling?)
once posted a canonical list of one line perl programs to do many common
command-line tasks.
It included:
# run contents of "my_file" as a program
perl my_file

# run debugger "stand-alone"
perl -d -e 42

# run program, but with warnings
perl -w my_file

# run program under debugger
perl -d my_file

# just check syntax, with warnings
perl -wc my_file

# useful at end of "find foo -print"
perl -nle unlink

# simplest one-liner program
perl -e 'print "hello world!\n"'

# add first and penultimate columns
perl -lane 'print $F[0] + $F[-2]'

# just lines 15 to 17
perl -ne 'print if 15 .. 17' *.pod

# in-place edit of *.c files changing all foo to bar
perl -p -i.bak -e 's/\bfoo\b/bar/g' *.c

# command-line that prints the first 50 lines (cheaply)
perl -pe 'exit if $. > 50' f1 f2 f3 ...

# delete first 10 lines
perl -i.old -ne 'print unless 1 .. 10' foo.txt

# change all the isolated oldvar occurrences to newvar
perl -i.old -pe 's{\boldvar\b}{newvar}g' *.[chy]

# command-line that reverses the whole file by lines
perl -e 'print reverse <>' file1 file2 file3 ....

# find palindromes
perl -lne 'print if $_ eq reverse' /usr/dict/words

# command-line that reverse all the bytes in a file
perl -0777e 'print scalar reverse <>' f1 f2 f3 ...

# command-line that reverses the whole file by paragraphs
perl -00 -e 'print reverse <>' file1 file2 file3 ....

# increment all numbers found in these files
perl i.tiny -pe 's/(\d+)/ 1 + $1 /ge' file1 file2 ....

# command-line that shows each line with its characters backwards
perl -nle 'print scalar reverse $_' file1 file2 file3 ....

# delete all but lines beween START and END
perl -i.old -ne 'print unless /^START$/ .. /^END$/' foo.txt

# binary edit (careful!)
perl -i.bak -pe 's/Mozilla/Slopoke/g' /usr/local/bin/netscape

# look for dup words
perl -0777 -ne 'print "$.: doubled $_\n" while /\b(\w+)\b\s+\b\1\b/gi'

# command-line that prints the last 50 lines (expensively)
perl -e 'lines = <>; print @@lines[ $#lines .. $#lines-50' f1 f2 f3 ...

AWK One Liners

HANDY ONE-LINE SCRIPTS FOR AWK 30 April 2008
Compiled by Eric Pement - eric [at] pement.org version 0.27

Latest version of this file (in English) is usually at:
http://www.pement.org/awk/awk1line.txt

This file will also be available in other languages:
Chinese - http://ximix.org/translation/awk1line_zh-CN.txt

USAGE:

Unix: awk '/pattern/ {print "$1"}' # standard Unix shells
DOS/Win: awk '/pattern/ {print "$1"}' # compiled with DJGPP, Cygwin
awk "/pattern/ {print \"$1\"}" # GnuWin32, UnxUtils, Mingw

Note that the DJGPP compilation (for DOS or Windows-32) permits an awk
script to follow Unix quoting syntax '/like/ {"this"}'. HOWEVER, if the
command interpreter is CMD.EXE or COMMAND.COM, single quotes will not
protect the redirection arrows (<, >) nor do they protect pipes (|).
These are special symbols which require "double quotes" to protect them
from interpretation as operating system directives. If the command
interpreter is bash, ksh or another Unix shell, then single and double
quotes will follow the standard Unix usage.

Users of MS-DOS or Microsoft Windows must remember that the percent
sign (%) is used to indicate environment variables, so this symbol must
be doubled (%%) to yield a single percent sign visible to awk.

If a script will not need to be quoted in Unix, DOS, or CMD, then I
normally omit the quote marks. If an example is peculiar to GNU awk,
the command 'gawk' will be used. Please notify me if you find errors or
new commands to add to this list (total length under 65 characters). I
usually try to put the shortest script first. To conserve space, I
normally use '1' instead of '{print}' to print each line. Either one
will work.

FILE SPACING:

# double space a file
awk '1;{print ""}'
awk 'BEGIN{ORS="\n\n"};1'

# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
# NOTE: On Unix systems, DOS lines which have only CRLF (\r\n) are
# often treated as non-blank, and thus 'NF' alone will return TRUE.
awk 'NF{print $0 "\n"}'

# triple space a file
awk '1;{print "\n"}'

NUMBERING AND CALCULATIONS:

# precede each line by its line number FOR THAT FILE (left alignment).
# Using a tab (\t) instead of space will preserve margins.
awk '{print FNR "\t" $0}' files*

# precede each line by its line number FOR ALL FILES TOGETHER, with tab.
awk '{print NR "\t" $0}' files*

# number each line of a file (number on left, right-aligned)
# Double the percent signs if typing from the DOS command prompt.
awk '{printf("%5d : %s\n", NR,$0)}'

# number each line of file, but only print numbers if line is not blank
# Remember caveats about Unix treatment of \r (mentioned above)
awk 'NF{$0=++a " :" $0};1'
awk '{print (NF? ++a " :" :"") $0}'

# count lines (emulates "wc -l")
awk 'END{print NR}'

# print the sums of the fields of every line
awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}'

# add all fields in all lines and print the sum
awk '{for (i=1; i<=NF; i++) s=s+$i}; END{print s}'

# print every line after replacing each field with its absolute value
awk '{for (i=1; i<=NF; i++) if ($i < 0) $i = -$i; print }'
awk '{for (i=1; i<=NF; i++) $i = ($i < 0) ? -$i : $i; print }'

# print the total number of fields ("words") in all lines
awk '{ total = total + NF }; END {print total}' file

# print the total number of lines that contain "Beth"
awk '/Beth/{n++}; END {print n+0}' file

# print the largest first field and the line that contains it
# Intended for finding the longest string in field #1
awk '$1 > max {max=$1; maxline=$0}; END{ print max, maxline}'

# print the number of fields in each line, followed by the line
awk '{ print NF ":" $0 } '

# print the last field of each line
awk '{ print $NF }'

# print the last field of the last line
awk '{ field = $NF }; END{ print field }'

# print every line with more than 4 fields
awk 'NF > 4'

# print every line where the value of the last field is > 4
awk '$NF > 4'

STRING CREATION:

# create a string of a specific length (e.g., generate 513 spaces)
awk 'BEGIN{while (a++<513) s=s " "; print s}'

# insert a string of specific length at a certain character position
# Example: insert 49 spaces after column #6 of each input line.
gawk --re-interval 'BEGIN{while(a++<49)s=s " "};{sub(/^.{6}/,"&" s)};1'

ARRAY CREATION:

# These next 2 entries are not one-line scripts, but the technique
# is so handy that it merits inclusion here.

# create an array named "month", indexed by numbers, so that month[1]
# is 'Jan', month[2] is 'Feb', month[3] is 'Mar' and so on.
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", month, " ")

# create an array named "mdigit", indexed by strings, so that
# mdigit["Jan"] is 1, mdigit["Feb"] is 2, etc. Requires "month" array
for (i=1; i<=12; i++) mdigit[month[i]] = i

TEXT CONVERSION AND SUBSTITUTION:

# IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format
awk '{sub(/\r$/,"")};1' # assumes EACH line ends with Ctrl-M

# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format
awk '{sub(/$/,"\r")};1'

# IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format
awk 1

# IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format
# Cannot be done with DOS versions of awk, other than gawk:
gawk -v BINMODE="w" '1' infile >outfile

# Use "tr" instead.
tr -d \r <infile >outfile # GNU tr version 1.22 or higher

# delete leading whitespace (spaces, tabs) from front of each line
# aligns all text flush left
awk '{sub(/^[ \t]+/, "")};1'

# delete trailing whitespace (spaces, tabs) from end of each line
awk '{sub(/[ \t]+$/, "")};1'

# delete BOTH leading and trailing whitespace from each line
awk '{gsub(/^[ \t]+|[ \t]+$/,"")};1'
awk '{$1=$1};1' # also removes extra space between fields

# insert 5 blank spaces at beginning of each line (make page offset)
awk '{sub(/^/, " ")};1'

# align all text flush right on a 79-column width
awk '{printf "%79s\n", $0}' file*

# center all text on a 79-character width
awk '{l=length();s=int((79-l)/2); printf "%"(s+l)"s\n",$0}' file*

# substitute (find and replace) "foo" with "bar" on each line
awk '{sub(/foo/,"bar")}; 1' # replace only 1st instance
gawk '{$0=gensub(/foo/,"bar",4)}; 1' # replace only 4th instance
awk '{gsub(/foo/,"bar")}; 1' # replace ALL instances in a line

# substitute "foo" with "bar" ONLY for lines which contain "baz"
awk '/baz/{gsub(/foo/, "bar")}; 1'

# substitute "foo" with "bar" EXCEPT for lines which contain "baz"
awk '!/baz/{gsub(/foo/, "bar")}; 1'

# change "scarlet" or "ruby" or "puce" to "red"
awk '{gsub(/scarlet|ruby|puce/, "red")}; 1'

# reverse order of lines (emulates "tac")
awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }' file*

# if a line ends with a backslash, append the next line to it (fails if
# there are multiple lines ending with backslash...)
awk '/\\$/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' file*

# print and sort the login names of all users
awk -F ":" '{print $1 | "sort" }' /etc/passwd

# print the first 2 fields, in opposite order, of every line
awk '{print $2, $1}' file

# switch the first 2 fields of every line
awk '{temp = $1; $1 = $2; $2 = temp}' file

# print every line, deleting the second field of that line
awk '{ $2 = ""; print }'

# print in reverse order the fields of every line
awk '{for (i=NF; i>0; i--) printf("%s ",$i);print ""}' file

# concatenate every 5 lines of input, using a comma separator
# between fields
awk 'ORS=NR%5?",":"\n"' file

SELECTIVE PRINTING OF CERTAIN LINES:

# print first 10 lines of file (emulates behavior of "head")
awk 'NR < 11'

# print first line of file (emulates "head -1")
awk 'NR>1{exit};1'

# print the last 2 lines of a file (emulates "tail -2")
awk '{y=x "\n" $0; x=$0};END{print y}'

# print the last line of a file (emulates "tail -1")
awk 'END{print}'

# print only lines which match regular expression (emulates "grep")
awk '/regex/'

# print only lines which do NOT match regex (emulates "grep -v")
awk '!/regex/'

# print any line where field #5 is equal to "abc123"
awk '$5 == "abc123"'

# print only those lines where field #5 is NOT equal to "abc123"
# This will also print lines which have less than 5 fields.
awk '$5 != "abc123"'
awk '!($5 == "abc123")'

# matching a field against a regular expression
awk '$7 ~ /^[a-f]/' # print line if field #7 matches regex
awk '$7 !~ /^[a-f]/' # print line if field #7 does NOT match regex

# print the line immediately before a regex, but not the line
# containing the regex
awk '/regex/{print x};{x=$0}'
awk '/regex/{print (NR==1 ? "match on line 1" : x)};{x=$0}'

# print the line immediately after a regex, but not the line
# containing the regex
awk '/regex/{getline;print}'

# grep for AAA and BBB and CCC (in any order on the same line)
awk '/AAA/ && /BBB/ && /CCC/'

# grep for AAA and BBB and CCC (in that order)
awk '/AAA.*BBB.*CCC/'

# print only lines of 65 characters or longer
awk 'length > 64'

# print only lines of less than 65 characters
awk 'length < 64'

# print section of file from regular expression to end of file
awk '/regex/,0'
awk '/regex/,EOF'

# print section of file based on line numbers (lines 8-12, inclusive)
awk 'NR==8,NR==12'

# print line number 52
awk 'NR==52'
awk 'NR==52 {print;exit}' # more efficient on large files

# print section of file between two regular expressions (inclusive)
awk '/Iowa/,/Montana/' # case sensitive

SELECTIVE DELETION OF CERTAIN LINES:

# delete ALL blank lines from a file (same as "grep '.' ")
awk NF
awk '/./'

# remove duplicate, consecutive lines (emulates "uniq")
awk 'a !~ $0; {a=$0}'

# remove duplicate, nonconsecutive lines
awk '!a[$0]++' # most concise script
awk '!($0 in a){a[$0];print}' # most efficient script

CREDITS AND THANKS:

Special thanks to the late Peter S. Tillier (U.K.) for helping me with
the first release of this FAQ file, and to Daniel Jana, Yisu Dong, and
others for their suggestions and corrections.

For additional syntax instructions, including the way to apply editing
commands from a disk file instead of the command line, consult:

"sed & awk, 2nd Edition," by Dale Dougherty and Arnold Robbins
(O'Reilly, 1997)

"UNIX Text Processing," by Dale Dougherty and Tim O'Reilly (Hayden
Books, 1987)

"GAWK: Effective awk Programming," 3d edition, by Arnold D. Robbins
(O'Reilly, 2003) or at http://www.gnu.org/software/gawk/manual/

To fully exploit the power of awk, one must understand "regular
expressions." For detailed discussion of regular expressions, see
"Mastering Regular Expressions, 3d edition" by Jeffrey Friedl (O'Reilly,
2006).

The info and manual ("man") pages on Unix systems may be helpful (try
"man awk", "man nawk", "man gawk", "man regexp", or the section on
regular expressions in "man ed").

USE OF '\t' IN awk SCRIPTS: For clarity in documentation, I have used
'\t' to indicate a tab character (0x09) in the scripts. All versions of
awk should recognize this abbreviation.

#---end of file---

SED One Liners

-------------------------------------------------------------------------
USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) Dec. 29, 2005
Compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.5

Latest version of this file (in English) is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.pement.org/sed/sed1line.txt

This file will also available in other languages:
Chinese - http://sed.sourceforge.net/sed1line_zh-CN.html
Czech - http://sed.sourceforge.net/sed1line_cz.html
Dutch - http://sed.sourceforge.net/sed1line_nl.html
French - http://sed.sourceforge.net/sed1line_fr.html
German - http://sed.sourceforge.net/sed1line_de.html
Italian - (pending)
Portuguese - http://sed.sourceforge.net/sed1line_pt-BR.html
Spanish - (pending)


FILE SPACING:

# double space a file
sed G

# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'

# triple space a file
sed 'G;G'

# undo double-spacing (assumes even-numbered lines are always blank)
sed 'n;d'

# insert a blank line above every line which matches "regex"
sed '/regex/{x;p;x;}'

# insert a blank line below every line which matches "regex"
sed '/regex/G'

# insert a blank line above and below every line which matches "regex"
sed '/regex/{x;p;x;G;}'

NUMBERING:

# number each line of a file (simple left alignment). Using a tab (see
# note on '\t' at end of file) instead of space will preserve margins.
sed = filename | sed 'N;s/\n/\t/'

# number each line of a file (number on left, right-aligned)
sed = filename | sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /'

# number each line of file, but only print numbers if line is not blank
sed '/./=' filename | sed '/./N; s/\n/ /'

# count lines (emulates "wc -l")
sed -n '$='

TEXT CONVERSION AND SUBSTITUTION:

# IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format.
sed 's/.$//' # assumes that all lines end with CR/LF
sed 's/^M$//' # in bash/tcsh, press Ctrl-V then Ctrl-M
sed 's/\x0D$//' # works on ssed, gsed 3.02.80 or higher

# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format.
sed "s/$/`echo -e \\\r`/" # command line under ksh
sed 's/$'"/`echo \\\r`/" # command line under bash
sed "s/$/`echo \\\r`/" # command line under zsh
sed 's/$/\r/' # gsed 3.02.80 or higher

# IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format.
sed "s/$//" # method 1
sed -n p # method 2

# IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format.
# Can only be done with UnxUtils sed, version 4.0.7 or higher. The
# UnxUtils version can be identified by the custom "--text" switch
# which appears when you use the "--help" switch. Otherwise, changing
# DOS newlines to Unix newlines cannot be done with sed in a DOS
# environment. Use "tr" instead.
sed "s/\r//" infile >outfile # UnxUtils sed v4.0.7 or higher
tr -d \r <infile >outfile # GNU tr version 1.22 or higher

# delete leading whitespace (spaces, tabs) from front of each line
# aligns all text flush left
sed 's/^[ \t]*//' # see note on '\t' at end of file

# delete trailing whitespace (spaces, tabs) from end of each line
sed 's/[ \t]*$//' # see note on '\t' at end of file

# delete BOTH leading and trailing whitespace from each line
sed 's/^[ \t]*//;s/[ \t]*$//'

# insert 5 blank spaces at beginning of each line (make page offset)
sed 's/^/ /'

# align all text flush right on a 79-column width
sed -e :a -e 's/^.\{1,78\}$/ &/;ta' # set at 78 plus 1 space

# center all text in the middle of 79-column width. In method 1,
# spaces at the beginning of the line are significant, and trailing
# spaces are appended at the end of the line. In method 2, spaces at
# the beginning of the line are discarded in centering the line, and
# no trailing spaces appear at the end of lines.
sed -e :a -e 's/^.\{1,77\}$/ & /;ta' # method 1
sed -e :a -e 's/^.\{1,77\}$/ &/;ta' -e 's/\( *\)\1/\1/' # method 2

# substitute (find and replace) "foo" with "bar" on each line
sed 's/foo/bar/' # replaces only 1st instance in a line
sed 's/foo/bar/4' # replaces only 4th instance in a line
sed 's/foo/bar/g' # replaces ALL instances in a line
sed 's/\(.*\)foo\(.*foo\)/\1bar\2/' # replace the next-to-last case
sed 's/\(.*\)foo/\1bar/' # replace only the last case

# substitute "foo" with "bar" ONLY for lines which contain "baz"
sed '/baz/s/foo/bar/g'

# substitute "foo" with "bar" EXCEPT for lines which contain "baz"
sed '/baz/!s/foo/bar/g'

# change "scarlet" or "ruby" or "puce" to "red"
sed 's/scarlet/red/g;s/ruby/red/g;s/puce/red/g' # most seds
gsed 's/scarlet\|ruby\|puce/red/g' # GNU sed only

# reverse order of lines (emulates "tac")
# bug/feature in HHsed v1.5 causes blank lines to be deleted
sed '1!G;h;$!d' # method 1
sed -n '1!G;h;$p' # method 2

# reverse each character on the line (emulates "rev")
sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'

# join pairs of lines side-by-side (like "paste")
sed '$!N;s/\n/ /'

# if a line ends with a backslash, append the next line to it
sed -e :a -e '/\\$/N; s/\\\n//; ta'

# if a line begins with an equal sign, append it to the previous line
# and replace the "=" with a single space
sed -e :a -e '$!N;s/\n=/ /;ta' -e 'P;D'

# add commas to numeric strings, changing "1234567" to "1,234,567"
gsed ':a;s/\B[0-9]\{3\}\>/,&/;ta' # GNU sed
sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta' # other seds

# add commas to numbers with decimal points and minus signs (GNU sed)
gsed -r ':a;s/(^|[^0-9.])([0-9]+)([0-9]{3})/\1\2,\3/g;ta'

# add a blank line every 5 lines (after lines 5, 10, 15, 20, etc.)
gsed '0~5G' # GNU sed only
sed 'n;n;n;n;G;' # other seds

SELECTIVE PRINTING OF CERTAIN LINES:

# print first 10 lines of file (emulates behavior of "head")
sed 10q

# print first line of file (emulates "head -1")
sed q

# print the last 10 lines of a file (emulates "tail")
sed -e :a -e '$q;N;11,$D;ba'

# print the last 2 lines of a file (emulates "tail -2")
sed '$!N;$!D'

# print the last line of a file (emulates "tail -1")
sed '$!d' # method 1
sed -n '$p' # method 2

# print the next-to-the-last line of a file
sed -e '$!{h;d;}' -e x # for 1-line files, print blank line
sed -e '1{$q;}' -e '$!{h;d;}' -e x # for 1-line files, print the line
sed -e '1{$d;}' -e '$!{h;d;}' -e x # for 1-line files, print nothing

# print only lines which match regular expression (emulates "grep")
sed -n '/regexp/p' # method 1
sed '/regexp/!d' # method 2

# print only lines which do NOT match regexp (emulates "grep -v")
sed -n '/regexp/!p' # method 1, corresponds to above
sed '/regexp/d' # method 2, simpler syntax

# print the line immediately before a regexp, but not the line
# containing the regexp
sed -n '/regexp/{g;1!p;};h'

# print the line immediately after a regexp, but not the line
# containing the regexp
sed -n '/regexp/{n;p;}'

# print 1 line of context before and after regexp, with line number
# indicating where the regexp occurred (similar to "grep -A1 -B1")
sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h

# grep for AAA and BBB and CCC (in any order)
sed '/AAA/!d; /BBB/!d; /CCC/!d'

# grep for AAA and BBB and CCC (in that order)
sed '/AAA.*BBB.*CCC/!d'

# grep for AAA or BBB or CCC (emulates "egrep")
sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d # most seds
gsed '/AAA\|BBB\|CCC/!d' # GNU sed only

# print paragraph if it contains AAA (blank lines separate paragraphs)
# HHsed v1.5 must insert a 'G;' after 'x;' in the next 3 scripts below
sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;'

# print paragraph if it contains AAA and BBB and CCC (in any order)
sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;/BBB/!d;/CCC/!d'

# print paragraph if it contains AAA or BBB or CCC
sed -e '/./{H;$!d;}' -e 'x;/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d
gsed '/./{H;$!d;};x;/AAA\|BBB\|CCC/b;d' # GNU sed only

# print only lines of 65 characters or longer
sed -n '/^.\{65\}/p'

# print only lines of less than 65 characters
sed -n '/^.\{65\}/!p' # method 1, corresponds to above
sed '/^.\{65\}/d' # method 2, simpler syntax

# print section of file from regular expression to end of file
sed -n '/regexp/,$p'

# print section of file based on line numbers (lines 8-12, inclusive)
sed -n '8,12p' # method 1
sed '8,12!d' # method 2

# print line number 52
sed -n '52p' # method 1
sed '52!d' # method 2
sed '52q;d' # method 3, efficient on large files

# beginning at line 3, print every 7th line
gsed -n '3~7p' # GNU sed only
sed -n '3,${p;n;n;n;n;n;n;}' # other seds

# print section of file between two regular expressions (inclusive)
sed -n '/Iowa/,/Montana/p' # case sensitive

SELECTIVE DELETION OF CERTAIN LINES:

# print all of file EXCEPT section between 2 regular expressions
sed '/Iowa/,/Montana/d'

# delete duplicate, consecutive lines from a file (emulates "uniq").
# First line in a set of duplicate lines is kept, rest are deleted.
sed '$!N; /^\(.*\)\n\1$/!P; D'

# delete duplicate, nonconsecutive lines from a file. Beware not to
# overflow the buffer size of the hold space, or else use GNU sed.
sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P'

# delete all lines except duplicate lines (emulates "uniq -d").
sed '$!N; s/^\(.*\)\n\1$/\1/; t; D'

# delete the first 10 lines of a file
sed '1,10d'

# delete the last line of a file
sed '$d'

# delete the last 2 lines of a file
sed 'N;$!P;$!D;$d'

# delete the last 10 lines of a file
sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1
sed -n -e :a -e '1,10!{P;N;D;};N;ba' # method 2

# delete every 8th line
gsed '0~8d' # GNU sed only
sed 'n;n;n;n;n;n;n;d;' # other seds

# delete lines matching pattern
sed '/pattern/d'

# delete ALL blank lines from a file (same as "grep '.' ")
sed '/^$/d' # method 1
sed '/./!d' # method 2

# delete all CONSECUTIVE blank lines from file except the first; also
# deletes all blank lines from top and end of file (emulates "cat -s")
sed '/./,/^$/!d' # method 1, allows 0 blanks at top, 1 at EOF
sed '/^$/N;/\n$/D' # method 2, allows 1 blank at top, 0 at EOF

# delete all CONSECUTIVE blank lines from file except the first 2:
sed '/^$/N;/\n$/N;//D'

# delete all leading blank lines at top of file
sed '/./,$!d'

# delete all trailing blank lines at end of file
sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' # works on all seds
sed -e :a -e '/^\n*$/N;/\n$/ba' # ditto, except for gsed 3.02.*

# delete the last line of each paragraph
sed -n '/^$/{p;h;};/./{x;/./p;}'

SPECIAL APPLICATIONS:

# remove nroff overstrikes (char, backspace) from man pages. The 'echo'
# command may need an -e switch if you use Unix System V or bash shell.
sed "s/.`echo \\\b`//g" # double quotes required for Unix environment
sed 's/.^H//g' # in bash/tcsh, press Ctrl-V and then Ctrl-H
sed 's/.\x08//g' # hex expression for sed 1.5, GNU sed, ssed

# get Usenet/e-mail message header
sed '/^$/q' # deletes everything after first blank line

# get Usenet/e-mail message body
sed '1,/^$/d' # deletes everything up to first blank line

# get Subject header, but remove initial "Subject: " portion
sed '/^Subject: */!d; s///;q'

# get return address header
sed '/^Reply-To:/q; /^From:/h; /./d;g;q'

# parse out the address proper. Pulls out the e-mail address by itself
# from the 1-line return address header (see preceding script)
sed 's/ *(.*)//; s/>.*//; s/.*[:<] *//'

# add a leading angle bracket and space to each line (quote a message)
sed 's/^/> /'

# delete leading angle bracket & space from each line (unquote a message)
sed 's/^> //'

# remove most HTML tags (accommodates multiple-line tags)
sed -e :a -e 's/<[^>]*>//g;/</N;//ba'

# extract multi-part uuencoded binaries, removing extraneous header
# info, so that only the uuencoded portion remains. Files passed to
# sed must be passed in the proper order. Version 1 can be entered
# from the command line; version 2 can be made into an executable
# Unix shell script. (Modified from a script by Rahul Dhesi.)
sed '/^end/,/^begin/d' file1 file2 ... fileX | uudecode # vers. 1
sed '/^end/,/^begin/d' "$@" | uudecode # vers. 2

# sort paragraphs of file alphabetically. Paragraphs are separated by blank
# lines. GNU sed uses \v for vertical tab, or any unique char will do.
sed '/./{H;d;};x;s/\n/={NL}=/g' file | sort | sed '1s/={NL}=//;s/={NL}=/\n/g'
gsed '/./{H;d};x;y/\n/\v/' file | sort | sed '1s/\v//;y/\v/\n/'

# zip up each .TXT file individually, deleting the source file and
# setting the name of each .ZIP file to the basename of the .TXT file
# (under DOS: the "dir /b" switch returns bare filenames in all caps).
echo @echo off >zipup.bat
dir /b *.txt | sed "s/^\(.*\)\.TXT/pkzip -mo \1 \1.TXT/" >>zipup.bat

TYPICAL USE: Sed takes one or more editing commands and applies all of
them, in sequence, to each line of input. After all the commands have
been applied to the first input line, that line is output and a second
input line is taken for processing, and the cycle repeats. The
preceding examples assume that input comes from the standard input
device (i.e, the console, normally this will be piped input). One or
more filenames can be appended to the command line if the input does
not come from stdin. Output is sent to stdout (the screen). Thus:

cat filename | sed '10q' # uses piped input
sed '10q' filename # same effect, avoids a useless "cat"
sed '10q' filename > newfile # redirects output to disk

For additional syntax instructions, including the way to apply editing
commands from a disk file instead of the command line, consult "sed &
awk, 2nd Edition," by Dale Dougherty and Arnold Robbins (O'Reilly,
1997; http://www.ora.com), "UNIX Text Processing," by Dale Dougherty
and Tim O'Reilly (Hayden Books, 1987) or the tutorials by Mike Arst
distributed in U-SEDIT2.ZIP (many sites). To fully exploit the power
of sed, one must understand "regular expressions." For this, see
"Mastering Regular Expressions" by Jeffrey Friedl (O'Reilly, 1997).
The manual ("man") pages on Unix systems may be helpful (try "man
sed", "man regexp", or the subsection on regular expressions in "man
ed"), but man pages are notoriously difficult. They are not written to
teach sed use or regexps to first-time users, but as a reference text
for those already acquainted with these tools.

QUOTING SYNTAX: The preceding examples use single quotes ('...')
instead of double quotes ("...") to enclose editing commands, since
sed is typically used on a Unix platform. Single quotes prevent the
Unix shell from intrepreting the dollar sign ($) and backquotes
(`...`), which are expanded by the shell if they are enclosed in
double quotes. Users of the "csh" shell and derivatives will also need
to quote the exclamation mark (!) with the backslash (i.e., \!) to
properly run the examples listed above, even within single quotes.
Versions of sed written for DOS invariably require double quotes
("...") instead of single quotes to enclose editing commands.

USE OF '\t' IN SED SCRIPTS: For clarity in documentation, we have used
the expression '\t' to indicate a tab character (0x09) in the scripts.
However, most versions of sed do not recognize the '\t' abbreviation,
so when typing these scripts from the command line, you should press
the TAB key instead. '\t' is supported as a regular expression
metacharacter in awk, perl, and HHsed, sedmod, and GNU sed v3.02.80.

VERSIONS OF SED: Versions of sed do differ, and some slight syntax
variation is to be expected. In particular, most do not support the
use of labels (:name) or branch instructions (b,t) within editing
commands, except at the end of those commands. We have used the syntax
which will be portable to most users of sed, even though the popular
GNU versions of sed allow a more succinct syntax. When the reader sees
a fairly long command such as this:

sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d

it is heartening to know that GNU sed will let you reduce it to:

sed '/AAA/b;/BBB/b;/CCC/b;d' # or even
sed '/AAA\|BBB\|CCC/b;d'

In addition, remember that while many versions of sed accept a command
like "/one/ s/RE1/RE2/", some do NOT allow "/one/! s/RE1/RE2/", which
contains space before the 's'. Omit the space when typing the command.

OPTIMIZING FOR SPEED: If execution speed needs to be increased (due to
large input files or slow processors or hard disks), substitution will
be executed more quickly if the "find" expression is specified before
giving the "s/.../.../" instruction. Thus:

sed 's/foo/bar/g' filename # standard replace command
sed '/foo/ s/foo/bar/g' filename # executes more quickly
sed '/foo/ s//bar/g' filename # shorthand sed syntax

On line selection or deletion in which you only need to output lines
from the first part of the file, a "quit" command (q) in the script
will drastically reduce processing time for large files. Thus:

sed -n '45,50p' filename # print line nos. 45-50 of a file
sed -n '51q;45,50p' filename # same, but executes much faster

If you have any additional scripts to contribute or if you find errors
in this document, please send e-mail to the compiler. Indicate the
version of sed you used, the operating system it was compiled for, and
the nature of the problem. To qualify as a one-liner, the command line
must be 65 characters or less. Various scripts in this file have been
written or contributed by:

Al Aab # founder of "seders" list
Edgar Allen # various
Yiorgos Adamopoulos # various
Dale Dougherty # author of "sed & awk"
Carlos Duarte # author of "do it with sed"
Eric Pement # author of this document
Ken Pizzini # author of GNU sed v3.02
S.G. Ravenhall # great de-html script
Greg Ubben # many contributions & much help
-------------------------------------------------------------------------

Installing PHP File Navigator - Web file Manager on Solaris 10

wget http://phpfilenavigator.litoweb.net/PHPfileNavigator.zip
cd /usr/local/packages/
cp /export/home/shared/PHPfileNavigator.zip ./
cd tmp
cp ../PHPfileNavigator.zip ./
unzip PHPfileNavigator.zip
mv pfn-2.3.3 /usr/local/apache/htdocs/pfn2
cd usr/local/apache/htdocs/pfn2
mkdir -p data/logs tmp
chmod -R 777 data/conf data/logs tmp

Make sure PHP is compiled with GD

vi /usr/local/apache/php/php.ini
chenage the below for 99MB
upload_max_filesize = 99M

Create database for phpfilenavigator

server:localhost
DB: pfn
user: someadmin
pass: adminpass
prefix: pfn_

Common name: Administrator
user: admin
pass: adminpass
email: someone@gmail.com

Root: Main
Path: /usr/local/apache/htdocs/
doc root: /
web: www.akash.com

http://www.akash.com/pfn2/instalar/index.php?paso=1&idioma=en
cp data/conf/default-example.inc.php data/conf/default.inc.php

cd /usr/local/apache/htdocs/pfn2
mv instalar instalar-org

Access : http://www.akash.com/pfn2

Yahoo !!!!!!!

Installing Gant on Solaris 10

cd /usr/local/
/usr/local/bin/tar -xvzf /usr/local/packages/gant-1.9.1-_groovy-1.7.0.tgz
mv gant-1.9.1 gant

The script $GANT_HOME/bin/gant for systems with a Posix shell, or
$GANT_HOME/bin/gant.bat on Windows is the mechanism for launching a Gant run.

Distributions 1a and 1b only include the direct Gant materials. The Maven
target set depends on use of the Maven Ant tasks, and the Ivy tool depends on
the Ivy jar, these will have to be downloaded and installed into
$GANT_HOME/lib unless they are already available on on your CLASSPATH.

Installing Gradle on Solaris 10

cd /usr/local/
unzip /usr/local/packages/gradle-0.8-all.zip
mv gradle-0.8 gradle

export JAVA_HOME=/usr/local/java/jdk1.6.0_18
export PATH=$JAVA_HOME/bin:$PATH

Installing Groovy on Solaris 10

cd /usr/local/
unzip /usr/local/packages/groovy-binary-1.7.0.zip
mv groovy-1.7.0 groovy

export JAVA_HOME=/usr/local/java/jdk1.6.0_18
export PATH=$JAVA_HOME/bin:$PATH

To check
/usr/local/groovy/bin/groovysh -version
Groovy Shell 1.7.0

Installing and Using Ivy on Solaris 10

To Install

cd /usr/local/packages/
wget http://www.takeyellow.com/apachemirror/ant/ivy/2.1.0/apache-ivy-2.1.0-bin-with-deps.tar.gz

cd /usr/local/
/usr/local/bin/tar -xvzf /usr/local/packages/apache-ivy-2.1.0-bin-with-deps.tar.gz
mv apache-ivy-2.1.0 ivy

cp /usr/local/ivy/ivy-2.1.0.jar /usr/local/ant/lib/

To Use

cp -R /usr/local/ivy/src/example/hello-ivy /export/home/entbld/hello-ivy
cd /export/home/entbld/hello-ivy
ant

Installing phpMyAdmin on Solaris 10

cd /usr/local/apache/htdocs
/usr/local/bin/tar -xvzf ../../packages/phpMyAdmin-3.2.5-all-languages.tar.gz
mv phpMyAdmin-3.2.5-all-languages phpmyadmin

cd /usr/local/apache/htdocs/phpMyAdmin

For new
mkdir config # create directory for saving
chmod o+rw config # give it world writable permissions
To edit current
cp config.inc.php config/ # copy current configuration for editing
chmod o+w config/config.inc.php # give it world writable permissions

http://akash/phpmyadmin/setup

To revert back permission to secure

mv config/config.inc.php . # move file to current directory
chmod o-rw config.inc.php # remove world read and write permissions

If using phpMyAdmin create a file called .htaccess in the phpMyAdmin install directory and add these lines:
This makes it so that phpMyAdmin can only be accessed from the localhost.

vi .htaccess
IndexIgnore *
order deny,allow
deny from all
allow from 127.0.0.1

To access
http://akash/phpmyadmin

Installing PHP5 from source on Solaris 10

cd /usr/local/src/
/usr/local/bin/tar -xvzf ../packages/php-5.3.1.tar.gz


cd php-5.3.1/

export PATH=/usr/sfw/bin:/usr/sbin:/usr/bin:/usr/local/ant/bin:/usr/sbin:/usr/bin:/usr/openwin/bin:/usr/dt/bin:/usr/ccs/bin:/usr/local/bin:/opt/csw/bin

./configure \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql/5.1.42 \
--with-openssl \
--prefix=/usr/local/apache/php \
--with-config-file-path=/usr/local/apache/php \
--disable-cgi \
--with-zlib \
--with-gd \
--with-gettext \
--with-gdbm

make
make install

If file /usr/local/apache/modules/libphp5.so does not exist
cp -p .libs/libphp5.so /usr/local/apache/modules

cp -p php.ini-production /usr/local/apache/php/php.ini

# Use for PHP 5.x:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script php

# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php

AddType text/html php

# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps


Restart Apache

# /usr/local/apache/bin/apachectl -k stop
# /usr/local/apache/bin/apachectl -f /usr/local/apache/conf/httpd.conf


Perform these sanity checks to verify your install went OK:

/usr/local/apache/bin/httpd -t
/usr/local/apache/bin/httpd -v
/usr/local/apache/bin/httpd -V
/usr/local/apache/bin/httpd -S
/usr/local/apache/bin/httpd -l


Access your webserver with telnet. Type HEAD / HTTP/1.0 followed by a blank line:


Add the below lines in index.html

<p>
<b>An Example of PHP in Action</b><br />
<?php echo "The Current Date and Time is: <br>";
echo date("g:i A l, F j Y.");?>
</p>
<h2>PHP Information</h2>
<p>
<?php phpinfo(); ?>
</p>


And copy index.html to index.php

To Start at Boot

cp /usr/local/apache/bin/apachectl /etc/init.d/

Installing MySQL on Solaris

1. Add mysql user id and group

# groupadd -g 300 mysql
# useradd -u 300 -g 300 -d /export/home/mysql -s /usr/bin/bash -c "MySQL DBA" mysql
# passwd mysql

2. Login as mysql

# su - mysql (or exec login mysql)

vi .bash_profile

PS1='$PWD: '
MYSQL_BASE=/usr/local/mysql
MYSQL_HOME=$MYSQL_BASE/5.1.42
export MYSQL_BASE MYSQL_HOME
PATH=$PATH:/usr/local/bin:/usr/bin:$MYSQL_HOME/bin
export PATH

3. Create the following base (parent) directory to download the MySQL software into.

# mkdir -p /usr/local/mysql
# export MYSQL_NAME=mysql01

The directory pattern of "mysql01" will be used to uniquely identify all physical files associated with
this specific MySQL database server.

4. Setup data directory structure

# mkdir -p /storage/db01/mysql/$MYSQL_NAME/data

5. Setup mysql administration directory structure
# mkdir -p /storage/db03/mysql/$MYSQL_NAME
# cd /storage/db03/mysql/$MYSQL_NAME/
# mkdir logs errors sql startup run


6. Setup binary log structure
# mkdir -p /storage/db02/mysql/$MYSQL_NAME/binlogs

7. Setup backup directory structure for backups and exports.
# mkdir -p /storage/db04/mysql/$MYSQL_NAME
# mkdir /storage/db04/mysql/$MYSQL_NAME/backups
# mkdir /storage/db04/mysql/$MYSQL_NAME/exports

8. Set permissions and ownership for MySQL file directories.
# chmod -R 750 /storage/db*/mysql/* /usr/local/mysql
# chown -R mysql:mysql /storage/db*/mysql/* /usr/local/mysql

9. Setup the MySQL software (as the MySQL OS user, not the root OS user)

$ cd /usr/local/mysql
$ /usr/local/bin/tar -xvzf ../packages/mysql-5.1.42-solaris10-sparc.tar.gz
$ ln -s mysql-5.1.42-solaris10-sparc 5.1.42
$ cp $MYSQL_HOME/support-files/my-small.cnf $MYSQL_HOME/my.cnf

10. Update my.cbf file

Add the following entries to the my.cnf file to the [mysqld] group.
This separates all your dynamic administration files, data files, and
binary log files to different locations. A separate port is defined away
from the default.


vi $MYSQL_HOME/my.cnf

[mysqld]
log-error=/storage/db03/mysql/mysql01/errors/mysql01.err
pid-file=/storage/db03/mysql/mysql01/mysql01.pid
datadir=/storage/db01/mysql/mysql01/data
basedir=/usr/local/mysql/5.1.42
log-bin=/storage/db02/mysql/mysql01/mysql-bin


11. Create the mysql database files for the MySQL instance. This will create
the default database schemas and database files.


$ cd $MYSQL_HOME
$ scripts/mysql_install_db --datadir=/storage/db01/mysql/mysql01/data --basedir=$MYSQL_HOME

Verify data files and directories have been created in the datadir directory.

$ cd /storage/db01/mysql/mysql01/data
$ ls

ib_logfile0 ib_logfile1 ibdata1 mysql test


12. Start the MySQL database server pointing to the defined locations.

$ cd /usr/local/mysql/5.1.24
$ bin/mysqld_safe --defaults-file=$MYSQL_HOME/my.cnf &


13. Updae passwords

# cd /usr/local/mysql/5.1.42

# ./bin/mysqladmin -u root -p password 'goodpass'
# ./bin/mysqladmin -u root -h localhost -p password 'goodpass'
# ./bin/mysqladmin -u root -h akash -p password 'goodpass'


$ cd $MYSQL_HOME
$ bin/mysql_secure_installation

Shutdown the MySQL server to verify you can shutdown and startup the MySQL instance.

$ mysqladmin --defaults-file=$MYSQL_HOME/my.cnf shutdown -uroot -p
$ cd $MYSQL_HOME

$ bin/mysqld_safe --defaults-file=$MYSQL_HOME/my.cnf

You're up and running have fun.

Installing Apache 2 from source on Solaris 10

To Install

Download the package httpd-2.2.14.tar.gz from apache

bash-3.00#cd /usr/local/src/
bash-3.00#/usr/local/bin/tar -xvzf ../packages/httpd-2.2.14.tar.gz
bash-3.00#cd httpd-2.2.14/
bash-3.00#./configure --prefix=/usr/local/apache \
--enable-so \
--enable-cgi \
--enable-info \
--enable-rewrite \
--enable-speling \
--enable-usertrack \
--enable-deflate \
--enable-ssl \
--enable-proxy \
--enable-dav \
--enable-example \
--enable-mime-magic

Note : http://httpd.apache.org/docs/2.2/programs/configure.html for adding more option

make
make install

To Check the compile modules
/usr/local/apache/bin/httpd -l

To Use the Config file
bash-3.00# /usr/local/apache/bin/apachectl -f /usr/local/apache/conf/httpd.conf

To Stop
bash-3.00#/usr/local/apache/bin/apachectl -k stop
bash-3.00#/usr/local/apache/bin/apachectl -k graceful-stop

To Restart
bash-3.00#/usr/local/apache/bin/apachectl -k restart


Adding to init.d to start automatically
bash-3.00#cp /usr/local/apache/bin/apachectl /etc/init.d/

To test
bash-3.00# /etc/init.d/apachectl stop
bash-3.00# /etc/init.d/apachectl start

Installing Apache http on Solaris 10

wget ftp://ftp.sunfreeware.com/pub/freeware/sparc/10/apr-1.2.2-sol10-sparc-local.gz
wget ftp://ftp.sunfreeware.com/pub/freeware/sparc/10/aprutil-1.2.2-sol10-sparc-local.gz
wget ftp://ftp.sunfreeware.com/pub/freeware/sparc/10/expat-2.0.1-sol10-sparc-local.gz
wget ftp://ftp.sunfreeware.com/pub/freeware/sparc/10/apache-2.2.14-sol10-sparc-local.gz

Install Pre-Req:
bash-3.00# pkgadd -d apr-1.2.2-sol10-sparc-local
bash-3.00# pkgadd -d aprutil-1.2.2-sol10-sparc-local
bash-3.00# pkgadd -d expat-2.0.1-sol10-sparc-local

Main Install:
bash-3.00# cd /usr/local/packages
bash-3.00# cp apache-2.2.14-sol10-sparc-local.gz tmp/
bash-3.00# cd tmp/
bash-3.00# gzip -d apache-2.2.14-sol10-sparc-local.gz

To Start
bash-3.00# /usr/local/apache2/bin/apachectl -f /usr/local/apache2/conf/httpd.conf

To Stop
bash-3.00#/usr/local/apache2/bin/apachectl -k stop
bash-3.00#/usr/local/apache2/bin/apachectl -k graceful-stop

To Restart
bash-3.00#/usr/local/apache2/bin/apachectl -k restart

Running Maven Project

mvn --version
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
cd my-app
mvn package
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App

Installing Apache Maven

cd /usr/local/packages/
wget http://apache.multihomed.net/maven/binaries/apache-maven-2.2.1-bin.tar.gz

cd /usr/local
/usr/local/bin/tar -xvzf /usr/local/packages/apache-maven-2.2.1-bin.tar.gz
mv apache-maven-2.2.1 maven

export M2_HOME=/usr/local/maven
export M2=$M2_HOME/bin
export MAVEN_OPTS="-Xms256m -Xmx256m"
export PATH=$M2:$PATH
export JAVA_HOME=/usr/local/java/jdk1.6.0_18
export PATH=$JAVA_HOME/bin:$PATH

mvn --version

Installing Apache ANT

wget "http://mirror.cc.columbia.edu/pub/software/apache/ant/binaries/apache-ant-1.8.0RC1-bin.tar.gz"

bash-3.00# cd /usr/local
bash-3.00# /usr/local/bin/tar -xvzf packages/apache-ant-1.8.0RC1-bin.tar.gz

Add the below lines in .bashrc

# apache ant
ANT_HOME=/usr/local/ant
PATH=$PATH:$ANT_HOME/bin
export ANT_HOME PATH

# ant -version
Apache Ant version 1.8.0RC1 compiled on January 5 2010

Wednesday, November 24, 2010

HTML color codes and names

About color codes and how to apply

HTML color codes are hexadecimal triplets representing the colors red, green, and blue. For example, in the the color red, the color code is FF0000, which is '255' red, '0' green, and '0' blue.

Major hexadecimal color codes

ColorColor CodeColorColor Code
Red #FF0000White#FFFFFF
Turquoise#00FFFFLight Grey#C0C0C0
Light Blue#0000FFDark Grey#808080
Dark Blue #0000A0Black#000000
Light Purple #FF0080Orange#FF8040
Dark Purple #800080Brown#804000
Yellow#FFFF00Burgundy#800000
Pastel Green#00FF00Forest Green#808000
Pink#FF00FFGrass Green#408080

Color code chart

COLOR NAMECODECOLOR
Black#000000Black
Gray0#150517Gray0
Gray18#250517Gray18
Gray21#2B1B17Gray21
Gray23#302217Gray23
Gray24#302226Gray24
Gray25#342826Gray25
Gray26#34282CGray26
Gray27#382D2CGray27
Gray28#3b3131Gray28
Gray29#3E3535Gray29
Gray30#413839Gray30
Gray31#41383CGray31
Gray32#463E3FGray32
Gray34#4A4344Gray34
Gray35#4C4646Gray35
Gray36#4E4848Gray36
Gray37#504A4BGray37
Gray38#544E4FGray38
Gray39#565051Gray39
Gray40#595454Gray40
Gray41#5C5858Gray41
Gray42#5F5A59Gray42
Gray43#625D5DGray43
Gray44#646060Gray44
Gray45#666362Gray45
Gray46#696565Gray46
Gray47#6D6968Gray47
Gray48#6E6A6BGray48
Gray49#726E6DGray49
Gray50#747170Gray50
Gray#736F6EGray
Slate Gray4#616D7ESlate Gray4
Slate Gray#657383Slate Gray
Light Steel Blue4#646D7ELight Steel Blue4
Light Slate Gray#6D7B8DLight Slate Gray
Cadet Blue4#4C787ECadet Blue4
Dark Slate Gray4#4C7D7EDark Slate Gray4
Thistle4#806D7EThistle4
Medium Slate Blue#5E5A80Medium Slate Blue
Medium Purple4#4E387EMedium Purple4
Midnight Blue#151B54Midnight Blue
Dark Slate Blue#2B3856Dark Slate Blue
Dark Slate Gray#25383CDark Slate Gray
Dim Gray#463E41Dim Gray
Cornflower Blue#151B8DCornflower Blue
Royal Blue4#15317ERoyal Blue4
Slate Blue4#342D7ESlate Blue4
Royal Blue#2B60DERoyal Blue
Royal Blue1#306EFFRoyal Blue1
Royal Blue2#2B65ECRoyal Blue2
Royal Blue3#2554C7Royal Blue3
Deep Sky Blue#3BB9FFDeep Sky Blue
Deep Sky Blue2#38ACECDeep Sky Blue2
Slate Blue#357EC7Slate Blue
Deep Sky Blue3#3090C7Deep Sky Blue3
Deep Sky Blue4#25587EDeep Sky Blue4
Dodger Blue#1589FFDodger Blue
Dodger Blue2#157DECDodger Blue2
Dodger Blue3#1569C7Dodger Blue3
Dodger Blue4#153E7EDodger Blue4
Steel Blue4#2B547ESteel Blue4
Steel Blue#4863A0Steel Blue
Slate Blue2#6960ECSlate Blue2
Violet#8D38C9Violet
Medium Purple3#7A5DC7Medium Purple3
Medium Purple#8467D7Medium Purple
Medium Purple2#9172ECMedium Purple2
Medium Purple1#9E7BFFMedium Purple1
Light Steel Blue#728FCELight Steel Blue
Steel Blue3#488AC7Steel Blue3
Steel Blue2#56A5ECSteel Blue2
Steel Blue1#5CB3FFSteel Blue1
Sky Blue3#659EC7Sky Blue3
Sky Blue4#41627ESky Blue4
Slate Blue#737CA1Slate Blue
Slate Blue#737CA1Slate Blue
Slate Gray3#98AFC7Slate Gray3
Violet Red#F6358AViolet Red
Violet Red1#F6358AViolet Red1
Violet Red2#E4317FViolet Red2
Deep Pink#F52887Deep Pink
Deep Pink2#E4287CDeep Pink2
Deep Pink3#C12267Deep Pink3
Deep Pink4#7D053FDeep Pink4
Medium Violet Red#CA226BMedium Violet Red
Violet Red3#C12869Violet Red3
Firebrick#800517Firebrick
Violet Red4#7D0541Violet Red4
Maroon4#7D0552Maroon4
Maroon#810541Maroon
Maroon3#C12283Maroon3
Maroon2#E3319DMaroon2
Maroon1#F535AAMaroon1
Magenta#FF00FFMagenta
Magenta1#F433FFMagenta1
Magenta2#E238ECMagenta2
Magenta3#C031C7Magenta3
Medium Orchid#B048B5Medium Orchid
Medium Orchid1#D462FFMedium Orchid1
Medium Orchid2#C45AECMedium Orchid2
Medium Orchid3#A74AC7Medium Orchid3
Medium Orchid4#6A287EMedium Orchid4
Purple#8E35EFPurple
Purple1#893BFFPurple1
Purple2#7F38ECPurple2
Purple3#6C2DC7Purple3
Purple4#461B7EPurple4
Dark Orchid4#571B7eDark Orchid4
Dark Orchid#7D1B7EDark Orchid
Dark Violet#842DCEDark Violet
Dark Orchid3#8B31C7Dark Orchid3
Dark Orchid2#A23BECDark Orchid2
Dark Orchid1#B041FFDark Orchid1
Plum4#7E587EPlum4
Pale Violet Red#D16587Pale Violet Red
Pale Violet Red1#F778A1Pale Violet Red1
Pale Violet Red2#E56E94Pale Violet Red2
Pale Violet Red3#C25A7CPale Violet Red3
Pale Violet Red4#7E354DPale Violet Red4
Plum#B93B8FPlum
Plum1#F9B7FFPlum1
Plum2#E6A9ECPlum2
Plum3#C38EC7Plum3
Thistle#D2B9D3Thistle
Thistle3#C6AEC7Thistle3
Lavender Blush2#EBDDE2Lavender Blush2
Lavender Blush3#C8BBBELavender Blush3
Thistle2#E9CFECThistle2
Thistle1#FCDFFFThistle1
Lavender#E3E4FALavender
Lavender Blush#FDEEF4Lavender Blush
Light Steel Blue1#C6DEFFLight Steel Blue1
Light Blue#ADDFFFLight Blue
Light Blue1#BDEDFFLight Blue1
Light Cyan#E0FFFFLight Cyan
Slate Gray1#C2DFFFSlate Gray1
Slate Gray2#B4CFECSlate Gray2
Light Steel Blue2#B7CEECLight Steel Blue2
Turquoise1#52F3FFTurquoise1
Cyan#00FFFFCyan
Cyan1#57FEFFCyan1
Cyan2#50EBECCyan2
Turquoise2#4EE2ECTurquoise2
Medium Turquoise#48CCCDMedium Turquoise
Turquoise#43C6DBTurquoise
Dark Slate Gray1#9AFEFFDark Slate Gray1
Dark Slate Gray2#8EEBECDark slate Gray2
Dark Slate Gray3#78c7c7Dark Slate Gray3
Cyan3#46C7C7Cyan3
Turquoise3#43BFC7Turquoise3
Cadet Blue3#77BFC7Cadet Blue3
Pale Turquoise3#92C7C7Pale Turquoise3
Light Blue2#AFDCECLight Blue2
Dark Turquoise#3B9C9CDark Turquoise
Cyan4#307D7ECyan4
Light Sea Green#3EA99FLight Sea Green
Light Sky Blue#82CAFALight Sky Blue
Light Sky Blue2#A0CFECLight Sky Blue2
Light Sky Blue3#87AFC7Light Sky Blue3
Sky Blue#82CAFFSky Blue
Sky Blue2#79BAECSky Blue2
Light Sky Blue4#566D7ELight Sky Blue4
Sky Blue#6698FFSky Blue
Light Slate Blue#736AFFLight Slate Blue
Light Cyan2#CFECECLight Cyan2
Light Cyan3#AFC7C7Light Cyan3
Light Cyan4#717D7DLight Cyan4
Light Blue3#95B9C7Light Blue3
Light Blue4#5E767ELight Blue4
Pale Turquoise4#5E7D7EPale Turquoise4
Dark Sea Green4#617C58Dark Sea Green4
Medium Aquamarine#348781Medium Aquamarine
Medium Sea Green#306754Medium Sea Green
Sea Green#4E8975Sea Green
Dark Green#254117Dark Green
Sea Green4#387C44Sea Green4
Forest Green#4E9258Forest Green
Medium Forest Green#347235Medium Forest Green
Spring Green4#347C2CSpring Green4
Dark Olive Green4#667C26Dark Olive Green4
Chartreuse4#437C17Chartreuse4
Green4#347C17Green4
Medium Spring Green#348017Medium Spring Green
Spring Green#4AA02CSpring Green
Lime Green#41A317Lime Green
Spring Green#4AA02CSpring Green
Dark Sea Green#8BB381Dark Sea Green
Dark Sea Green3#99C68EDark Sea Green3
Green3#4CC417Green3
Chartreuse3#6CC417Chartreuse3
Yellow Green#52D017Yellow Green
Spring Green3#4CC552Spring Green3
Sea Green3#54C571Sea Green3
Spring Green2#57E964Spring Green2
Spring Green1#5EFB6ESpring Green1
Sea Green2#64E986Sea Green2
Sea Green1#6AFB92Sea Green1
Dark Sea Green2#B5EAAADark Sea Green2
Dark Sea Green1#C3FDB8Dark Sea Green1
Green#00FF00Green
Lawn Green#87F717Lawn Green
Green1#5FFB17Green1
Green2#59E817Green2
Chartreuse2#7FE817Chartreuse2
Chartreuse#8AFB17Chartreuse
Green Yellow#B1FB17Green Yellow
Dark Olive Green1#CCFB5DDark Olive Green1
Dark Olive Green2#BCE954Dark Olive Green2
Dark Olive Green3#A0C544Dark Olive Green3
Yellow#FFFF00Yellow
Yellow1#FFFC17Yellow1
Khaki1#FFF380Khaki1
Khaki2#EDE275Khaki2
Goldenrod#EDDA74Goldenrod
Gold2#EAC117Gold2
Gold1#FDD017Gold1
Goldenrod1#FBB917Goldenrod1
Goldenrod2#E9AB17Goldenrod2
Gold#D4A017Gold
Gold3#C7A317Gold3
Goldenrod3#C68E17Goldenrod3
Dark Goldenrod#AF7817Dark Goldenrod
Khaki#ADA96EKhaki
Khaki3#C9BE62Khaki3
Khaki4#827839Khaki4
Dark Goldenrod1#FBB117Dark Goldenrod1
Dark Goldenrod2#E8A317Dark Goldenrod2
Dark Goldenrod3#C58917Dark Goldenrod3
Sienna1#F87431Sienna1
Sienna2#E66C2CSienna2
Dark Orange#F88017Dark Orange
Dark Orange1#F87217Dark Orange1
Dark Orange2#E56717Dark Orange2
Dark Orange3#C35617Dark Orange3
Sienna3#C35817Sienna3
Sienna#8A4117Sienna
Sienna4#7E3517Sienna4
Indian Red4#7E2217Indian Red4
Dark Orange3#7E3117Dark Orange3
Salmon4#7E3817Salmon4
Dark Goldenrod4#7F5217Dark Goldenrod4
Gold4#806517Gold4
Goldenrod4#805817Goldenrod4
Light Salmon4#7F462CLight Salmon4
Chocolate#C85A17Chocolate
Coral3#C34A2CCoral3
Coral2#E55B3CCoral2
Coral#F76541Coral
Dark Salmon#E18B6BDark Salmon
Salmon1#F88158Pale Turquoise4
Salmon2#E67451Salmon2
Salmon3#C36241Salmon3
Light Salmon3#C47451Light Salmon3
Light Salmon2#E78A61Light Salmon2
Light Salmon#F9966BLight Salmon
Sandy Brown#EE9A4DSandy Brown
Hot Pink#F660ABHot Pink
Hot Pink1#F665ABHot Pink1
Hot Pink2#E45E9DHot Pink2
Hot Pink3#C25283Hot Pink3
Hot Pink4#7D2252Hot Pink4
Light Coral#E77471Light Coral
Indian Red1#F75D59Indian Red1
Indian Red2#E55451Indian Red2
Indian Red3#C24641Indian Red3
Red#FF0000Red
Red1#F62217Red1
Red2#E41B17Red2
Firebrick1#F62817Firebrick1
Firebrick2#E42217Firebrick2
Firebrick3#C11B17Firebrick3
Pink#FAAFBEPink
Rosy Brown1#FBBBB9Rosy Brown1
Rosy Brown2#E8ADAARosy Brown2
Pink2#E7A1B0Pink2
Light Pink#FAAFBALight Pink
Light Pink1#F9A7B0Light Pink1
Light Pink2#E799A3Light Pink2
Pink3#C48793Pink3
Rosy Brown3#C5908ERosy Brown3
Rosy Brown#B38481Rosy Brown
Light Pink3#C48189Light Pink3
Rosy Brown4#7F5A58Rosy Brown4
Light Pink4#7F4E52Light Pink4
Pink4#7F525DPink4
Lavender Blush4#817679Lavendar Blush4
Light Goldenrod4#817339Light Goldenrod4
Lemon Chiffon4#827B60Lemon Chiffon4
Lemon Chiffon3#C9C299Lemon Chiffon3
Light Goldenrod3#C8B560Light Goldenrod3
Light Golden2#ECD672Light Golden2
Light Goldenrod#ECD872Light Goldenrod
Light Goldenrod1#FFE87CLight Goldenrod1
Lemon Chiffon2#ECE5B6Lemon Chiffon2
Lemon Chiffon#FFF8C6Lemon Chiffon
Light Goldenrod Yellow#FAF8CCLight Goldenrod Yellow

 

Installing ClearCase/ClearQuest/CCRC Client in widows using in silent mode

\\nas\\V711\WINDOWS\IM\1.4.1\installc.exe --launcher.ini silent-install.ini -input \\nas\V711\WINDOWS\response\win_cc_in_client.xml
\\nas\V711\WINDOWS\IM\1.4.1\installc.exe --launcher.ini silent-install.ini -input \\nas\V711\WINDOWS\response\win_cq_in_admin.xml
\\nas\V711\WINDOWS\IM\1.4.1\installc.exe --launcher.ini silent-install.ini -input \\nas\V711\WINDOWS\response\win_ccrc_in_client.xml

Tuesday, November 23, 2010

List of all of IBM Rational ClearCase/ClearQuest features for Linux (linux_x86)

com.ibm.rational.clearcaseunix.core                     - Core Function (Required)
com.ibm.rational.clearcaseunix.CC_MIN_STD_X             - Minimal Developer Installation
com.ibm.rational.clearcaseunix.CC_FULL                  - Full Function Installation
com.ibm.rational.clearcaseunix.CC_ONLY_SERVER_X         - ClearCase Server-Only Installation
com.ibm.rational.clearcaseunix.CC_MFC                   - ClearCase z/OS extensions
com.ibm.rational.clearcaseunix.MS_FULL                  - MultiSite Full Function Installation
com.ibm.rational.clearcase.gm                           - ClearCase MultiSite Global Monitoring (requires MS_FULL)
com.ibm.rational.clearcaseunix.MS_ONLY_SHIPPING_SERVER  - MultiSite Shipping Server Only
com.ibm.rational.clearcaseunix.CQ_CC_int                - ClearQuest Integration with ClearCase
com.ibm.rational.clearcaseunix.CM_Server                - CM Server for ClearCase Remote Clients

 
com.ibm.rational.clearquestunix.common                  - (Required) Core clearquest code
com.ibm.rational.clearquestunix.CQEC                    - Rational ClearQuest Client
com.ibm.rational.clearquestunix.admintools              - Administration Tools
com.ibm.rational.clearquestunix.cqcli                   - Command Line Interface
com.ibm.rational.clearquestunix.cmlibdoc                - CM Library Samples and Documenation
com.ibm.rational.clearquestunix.cqweb                   - ClearQuest WebServer (Web Component)
com.ibm.rational.clearquestunix.cmserver                - CM Server for ClearQuest Web (Web Component)
com.ibm.rational.clearquestunix.fulltextsearch          - Full Text Search Server (Web Component)
com.ibm.rational.clearquestunix.reportal                - Report Server for ClearQuest (Web Component)
com.ibm.rational.clearquestunix.CQ_ReportCrystal        - Report Server for Crystal Reports (Web Component)
com.ibm.rational.clearquestunix.shippingserver          - Multisite Shipping Server