$ ln -nsf <TARGET> <LINK>
Credit: Commandline-fu.
29 Monday Aug 2011
$ ln -nsf <TARGET> <LINK>
Credit: Commandline-fu.
13 Sunday Mar 2011
If you want to replace dots in a string, for example “a.string.with.dots”, by hyphens use the following trick
$ echo "a.string.with.dots" | tr "." "-"
That’s it!
Needless to say, other characters may also be substituted this way.
10 Thursday Mar 2011
Tags
In connection to my previous post on SVN intro, here’s a neat trick to list SVN commits by a user for a given date range:
$ for i in `svn log -r{2011-02-01}:HEAD | awk '$3 == "user" {print $1}'`; do svn log -v -$i;done
Note: It does not work in t/csh shells since you need a different looping structure (see a recent post on t/csh loops).
Reference: Command-Line-Fu.
29 Friday Jan 2010
#For Previous Command (for comparison) !-1 repeat whole command !! repeat (shortcut) !:0 command !^ first parameter !:1 first parameter !:1-4 first 4 parameters !$ last parameter !* all parameters !!:s/bash/zsh (or ^bash^zsh) !^:t just file name of first parameter !$:h just path of last parameter !-2$:r just file name without extension of first parameter For last but one command !-2 repeat last but one command !-2^ first parameter last but one command !-2$ last parameter last but one command !-2:2 second parameter of second but last command !-2:s/bash/zsh substitute bash by zsh in the last but one command
Most of them are applicable for bash as well.
Credit: copied from here.
29 Friday Jan 2010
Tags
calculator, cli, math, trigonometry, zsh
$ zmodload zsh/mathfunc $ echo $(( sin(1/4.0)**2 + cos(1/4.0)**2 - 1 )) -1.1102230246251565e-16 $ echo $(( pi = 4.0 * atan(1.0) )) 3.1415926535897931 $ echo $(( f = sin(0.3) )) 0.29552020666133955 $ print $((1e12 * rand48())) 847909677310.23413 $ print $(( rand48(seed) )) 0.0104348833470027
Notice that zsh/mathfunc must be loaded first!
Credit: copied from zsh-lovers.