Unix

script
$ script 
 * http://unixhelp.ed.ac.uk/CGI/man-cgi?script

hostname
HN=`hostname --short`

pipes

 * http://docstore.mik.ua/orelly/unix/upt/ch13_01.htm
 * http://www.cse.ohio-state.edu/~mamrak/CIS762/pipes_lab_notes.html
 * http://unixwiz.net/techtips/remap-pipe-fds.html

bash

 * http://www.cyberciti.biz/faq/bash-while-loop/

zip
unzip app.war -d A zip -r  ../app.war.
 * exploding a war
 * zipping up a war (from inside)

openssl
openssl x509 -in domainRootCAcert.pem -outform DER -out domainRootCAcert.der
 * Convert a 'pem' to a 'der'

SSH
keygen

client$ mkdir ~/.ssh client$ chmod 700 ~/.ssh client$ ssh-keygen -q -f ~/.ssh/id_rsa -t rsa Enter passphrase (empty for no passphrase): … Enter same passphrase again: … "Make sure you use the public key (id_rsa.pub in our example), and do not add any newlines or whitespace inside the key. To ensure you copy the key correctly, you can copy the key directly into the clipboard from Terminal.app:" $ cat ~/.ssh/id_rsa.pub | pbcopy
 * http://sial.org/howto/openssh/publickey-auth/
 * http://pkeck.myweb.uga.edu/ssh/
 * http://www.petefreitag.com/item/532.cfm
 * http://help.github.com/mac-key-setup/

Find
find. -path '*/.svn' -prune -o -type f -print | xargs -e grep -I -n -e PATTERN
 * http://content.hccfl.edu/pollock/Unix/FindCmd.htm
 * Ignoring .svn directories
 * http://stackoverflow.com/questions/2314643/how-can-i-get-find-to-ignore-svn-directories


 * http://en.wikipedia.org/wiki/Xargs
 * http://www.cyberciti.biz/faq/find-command-exclude-ignore-files/
 * http://www.liamdelahunty.com/tips/linux_find_exclude_multiple_directories.php

Listing an archive's contents without opening the archive find. -name "*.jar" -print -exec unzip -t {} \; |grep "QName" find. \( -type f -exec grep org/apache/commons/lang/StringUtils.class {} \; \) -exec ls -ld {} \; find. -name \*.sed find stage | grep war | xargs -I xxx mv xxx.
 * http://stackoverflow.com/questions/860187/access-restriction-on-class-due-to-restriction-on-required-library-rt-jar

Find *.txt file but ignore hidden .txt file such as .vimrc or .data.txt file: $ find. -type f \( -iname "*.txt" ! -iname ".*" \) Find all .dot files but ignore .htaccess file: $ find. -type f \( -iname ".*" ! -iname ".htaccess" \)

find. -type d \( -name media -o -name images -o -name backups \) -prune -o -print find edsengine-* -type d \( -name .svn \) -prune -o -print $ find stage -iwholename *APPNAME_6-6-9_TEST_20101028*/*.war -exec cp {} /tmp \;

Find all files except for those in brackets: find $FIND_DIR -type f \( ! -iname "*.*~*" ! -iname "*.BAK" ! -iname ".*" \) find $FIND_DIR -type f ! \( -iname "*.*~*" -o -iname "*.BAK" -o -iname ".*" \) find $FIND_DIR -type f ! \( -iname "*.*~*" -o -iname "*.BAK" -o -iname ".*" -o -iname "*.log" \) -exec tar zcvf ~/archive.tar.gz {} \;


 * 1) !/bin/bash


 * 1) This script can clean up files that were last accessed over 365 days ago.

USAGE="Usage: $0 dir1 dir2 dir3 ... dirN"

if [ "$#" == "0" ]; then echo "$USAGE" exit 1 fi

while (( "$#" )); do

if $(ls "$1") == "" ; then echo "Empty directory, nothing to be done." else find "$1" -type f -a -atime +365 -exec rm -i {} \; fi

shift

done

sed
$ find -name "*.php" | xargs sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' Removes all trailing newlines from PHP files under the current directory -- run from app/.
 * http://groups.google.com/group/cake-php/browse_thread/thread/2db873356d6c7611/fd0cef3068de456d

Zip
zip -r foo WEB-INF/* META-INF/* unzip a.zip -d toHere/inHere

Hyphens
touch ./-x touch -- -file.txt "'--' means that there are no more options to be passed and what comes after that is considered as argument (in this case a filename)."
 * http://www.unix.com/shell-programming-scripting/138210-not-able-create-any-file-name-start-hyphen-solaris.html

Cygwin XServer
client-$ startxwin client-$ /usr/bin/xhost + access control disabled, clients can connect from any host client-$ ssh remote remote-$ export DISPLAY=CL.IE.NT.IP:0 remote-$ startGuiOfSomeSort
 * http://x.cygwin.com/docs/ug/using.html

Nohup
nohup ./startWebLogic.sh > /dev/null 2>&1

Tar
tar cvf -. | (cd /root/; tar xvf -)
 * http://www.linuxquestions.org/questions/linux-general-1/tar-tar-cvf-|-cd-root-%3B-tar-xvf-353132/

Network
"Netcat on the other hand is a real network analysis tool, which does what you want it to do. If you type an LF, then it sends an LF. But SMTP requires the client to send CR-LF. Most servers would treat both CR and LF as a line change, but some servers try to be completely standards-compliant, most notably MS Hotmail."
 * http://fixunix.com/security/17957-telnet-vs-netcat.html

Wireshark
ip.addr==10.1.1.200 and ssl http
 * filter

nslookup

 * http://www.kloth.net/services/nslookup.php
 * http://www.kloth.net/services/dig.php
 * http://www.debianhelp.co.uk/nslookup.htm

Java

 * 1) !/bin/sh


 * 1)  Change to exe
 * 2)  chmod 775 run.sh
 * 3)   START - command in linux
 * 4)   nohup ./run.sh & >> /dev/null
 * 1)   nohup ./run.sh & >> /dev/null

APPROOT=/var/www/java/fuzzy/customer-work APPLIB=$APPROOT/lib

CLASSPATH=$CLASSPATH:$APPLIB/spring-128/spring.jar CLASSPATH=$CLASSPATH:$APPLIB/log4j/log4j-1.2.13.jar CLASSPATH=$CLASSPATH:$APPLIB/aop/aopalliance.jar:$APPLIB/aop/asm-1.5.3.jar:$APPLIB/aop/asm-attrs-1.5.3.jar CLASSPATH=$CLASSPATH:$APPLIB/commons/commons-codec-1.3.jar:$APPLIB/commons/commons-collections-3.2.jar:$APPLIB/commons/commons-dbcp-1.2.1.jar CLASSPATH=$CLASSPATH:$APPLIB/commons/commons-httpclient-3.0.1.jar:$APPLIB/commons/commons-logging-1.1.jar:$APPLIB/commons/commons-pool-1.3.jar CLASSPATH=$CLASSPATH:$APPLIB/velocity/velocity-1.4.jar:$APPLIB/velocity/velocity-dep-1.4.jar:$APPLIB/velocity/velocity-tools-1.2.jar CLASSPATH=$CLASSPATH:$APPLIB/velocity/velocity-tools-generic-1.2.jar:$APPLIB/velocity/velocity-tools-view-1.2.jar CLASSPATH=$CLASSPATH:$APPLIB/mail/mailapi.jar:$APPLIB/mail/activation.jar:$APPLIB/mail/mail.jar:$APPLIB/oracle/ojdbc14.jar CLASSPATH=$CLASSPATH:$APPROOT/bin

export CLASSPATH

printenv

/opt/bea/weblogic/jdk150_04/bin/java com.fuzzybearings.MainApplication