hfmt
hfmt [-ax] fmt [arg ...]
hfmt
converts input to some formated output. The format is given by i
fmt. The main usage will be to convert plain string to URL encoded and HTML encoded strings.%[flags]varb
..,#+-0123456789
cdoxXeEgGfUHD
UHD
are hfmt
specific. The meanings are:U
: URL formatH
: HTML formatD
: HTTP date format (rfc1123)\t \n \r \\
We have two type of usages:
hfmt
-a
[x
] fmt [str ...]hfmt
[-x
] fmt [num ...]-x
means non-ascii rune is hex decoded.fhmt
arguments means the field numbers. Field number "0
" is special, i.e., "0
" means whole line excluding trailing new line code '\n'. The command hfmt
splits tokenized lines.
term% hfmt -a '%H\n' 'AT&T' AT&T term% hfmt -a '%U\n' 'AT&T' AT%26T term% hfmt -a '%D\n' `{date -n} Sat, 01 Sep 2007 10:49:01 GMT term%
Example 2
term% hfmt -a '%U\n' 日本 日本 term% hfmt -ax '%U\n' 日本 %E6%97%A5%E6%9C%AC term%
Example 3
More complicated example:
term% ls -l --rw-rw-r-- M 43 web web 24 Sep 1 22:52 'AT and T' --rw-rw-r-- M 43 web web 254 Sep 1 19:46 'AT&T' term% ls -l | hfmt '%6d <a href="%U">%H</a>\n' 6 10 10 24 <a href="AT%20and%20T">AT and T</a> 254 <a href="AT%26T">AT&T</a> term%
http://plan9.aichi-u.ac.jp/netlib/cgitools/
hfmt
cannot handle integers larger than 32 bits.