perl -ane '$"=","; my @match = map { s/\.8\(1A\)//; s/mmu-miR-//; $_; } ($F[3] =~ /(\bmmu-.*?)(?:\s|,)/g); @match = ($F[1]) if !@match; print "$F[0]\t@match\n";' mouse.cons > ~/mouse.annot grep -l intalg * | xargs perl -pi.bak -e 's{a}{b}g; find ./ -name '*.c' -exec grep -q foo '{}' ';' -print grep -r --include=.c groff -t -e -mandoc -Tascii foo.1 | col -bx > foo.txt perl -e 'for (1..26) { print "$_ "; system "echo xynos | caesar $_"; }' perl -p -e 's/[\012\015]+/\012/g' ttt > uuu perl -pi.bak -e 's/[\012\015]+/\n/' perl -np -e 'if (\!/^>/) { s/(.{60})/$1\n/g; }' ce.fasta > ce2.fasta perl -e 'local $,= " ";for($i=0;$i<20;$i++){print map { rand(10) } (0..4); print "\n";}' > abc perl -ne 'chomp; print "$_\n" if 5 > (substr($_, -6, 6) =~ s/\|/|/g);' perl -ane '($m{$F[0]}=$F[1])&&next if$ARGV=~/ens2zfin/;print+($m{$F[0]}||"nope $F[0]"),"\n";' $ENV{HOME}/ens2zfin $ENV{HOME}/gold2 $t =()= $x =~ /abc/g open(SYL, "gzip -dcf $ffn|") || die "cannot open $ffn"; zoem -s foo=0 -e '\whilst{\let{\foo<20}}{\format{%~{.}{ }>20.}{{\foo}}\@{\N}\setx{foo}{\let{\foo+1}}}' find mcx -name '*.c' -print | grep -v 'evil-stuff' | xargs ctags -a -o mcx-tags find /path -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "your pattern"' \; read.table(file=gzfile(ffname_in), comment.char="", header=T, row.names=1, as.is=T, sep="\t", fill=T, quote="", na.strings="", check.names=F) rsync -Cavz foo bar C cvs-ignore mode a archive (preserve symlinks etc) v verbose z compress mysql -D -B -N -e 'show table status' | recol.pl 7 | perl -ne 'chomp; $s += $_; END { print "<<< $s >>>\n"; }' # recol.pl is cut-like perl script, not yet available. mysql -D -B -N -e 'show table status' | recol 7 | perl -ne 'chomp; $s += $_; END { $s /= 1<<30; printf "<<< %.2fG >>>\n", $s; }' SET PASSWORD FOR 'foo'@'%' = PASSWORD('bar'); winmail.dat files: tnef -f winmail.dat ktnef winmail.dat http://dev.mysql.com/doc/refman/5.0/en/adding-users.html adding user accounts, administration hell DBI my $hr = $dbh->selectall_hashref($utr_q, 'transcript_id'); my $mirs = $mir_q->fetchall_arrayref({}); an array of hashes indexed by column name. my $ar = $dbh->selectcol_arrayref("select id, name from table", { Columns=>[1,2] }); flatten out, useful for hash assignment as in my %bh = @{$dbh->selectcol_arrayref("...", { Columns => [1,2] })}; my $ar = selectall_arrayref($hit_q, {Slice => {}}); R format text over multiple lines thestr <- "ACTCACTAGTCGTAGCTAACTCACTAGTCGTAGCTAACTCACTAGTCGTAGCTAACTCAACTCACTAGTCGTAGCTAACTCACTAGTCGTAGCTAACTCACTAGTCGTAGCTAACTCA" thewidth <- 60 unlist(lapply(1:(1+nchar(thestr) %/% thewidth), function(x) { substr(thestr, thewidth*(x-1)+1, thewidth*x)} )) ps2pdf -dAutoRotatePages=/None to turn off orientation detection. other values: /All, /PageByPage. find -perm mode File's permission bits are exactly mode (octal or symbolic). Symbolic modes use mode 0 as a point of departure. -perm -mode All of the permission bits mode are set for the file. -perm +mode Any of the permission bits mode are set for the file. find ./ -print | xargs perl -pi.bak -e 's{a}{b}g;' find ./ -printf '%Ay%Am%Ad%AH%AM%AS %p\n' | sort -n flock -n /var/run/your.lockfile -c /your/script ------ PERL ------ local file handle sub newopen { my $path = shift; local *FH; # not my() nor our() open(FH, $path) or return undef; return *FH; # not \*FH! } $fh = newopen('/etc/passwd'); ------ CSH ------ cmd >& name The shell cannot presently redirect diagnostic output without also redirecting standard output, but `(command > output-file) >& error- file' is often an acceptable workaround. Either output-file or error- file may be `/dev/tty' to send output to the terminal. bindkey -v loop foreach f ( ls *.azm ) echo $f end conditionals if (expr) then ... else if (expr2) then ... else ... endif ------ BASH ------ set -o vi bind '"\t":menu-complete' bind '^F:reverse-search-history' bind '^G:forward-search-history' for f in rankings/*; do echo ${f##*/}; done for f in $(ls *.azm); do echo $f if ( .. ); then continue fi done if test "$ttt" != 0 -o -f $FILE; then fi if ( test $f == ${f%%.suffix} ); then echo "no suffix" else echo "have suffix" fi if test ! "$tab"; then if test -e $1 -o "$2"; then echo yes else echo no fi for ((i=1; i<100;i++));do echo $i; done ---- time format: % A literal `%'. C Name and command line arguments of the command being timed. D Average size of the process's unshared data area, in Kilobytes. E Elapsed real (wall clock) time used by the process, in [hours:]minutes:seconds. F Number of major, or I/O-requiring, page faults that occurred while the process was running. These are faults where the page has actually migrated out of primary memo- ry. I Number of file system inputs by the process. K Average total (data+stack+text) memory use of the process, in Kilobytes. M Maximum resident set size of the process during its lifetime, in Kilobytes. O Number of file system outputs by the process. P Percentage of the CPU that this job got. This is just user + system times divided by the total running time. It also prints a percentage sign. R Number of minor, or recoverable, page faults. These are pages that are not valid (so they fault) but which have not yet been claimed by other virtual pages. Thus the data in the page is still valid but the system tables must be updated. S Total number of CPU-seconds used by the system on behalf of the process (in kernel mode), in seconds. U Total number of CPU-seconds that the process used directly (in user mode), in sec- onds. W Number of times the process was swapped out of main memory. X Average amount of shared text in the process, in Kilobytes. Z System's page size, in bytes. This is a per-system constant, but varies between systems. c Number of times the process was context-switched involuntarily (because the time slice expired). e Elapsed real (wall clock) time used by the process, in seconds. k Number of signals delivered to the process. p Average unshared stack size of the process, in Kilobytes. r Number of socket messages received by the process. s Number of socket messages sent by the process. t Average resident set size of the process, in Kilobytes. w Number of times that the program was context-switched voluntarily, for instance while waiting for an I/O operation to complete. x Exit status of the command. http://www.scribd.com/doc/985254/Bash-Emacs-Editing-Mode-readline-Cheat-Sheet readline: from vi/vim to emacs: from emacs to vi/vim