在 Linux 下使用命令行的时候常常会遇到一些有趣的小技巧,日常生活中经常会用得着,记录下来供自己和感兴趣的人查阅:
aptitude search ~i --disable-column | grep -v "i.A" | cut -d " " -f 3
[ FILE1 -ot FILE2 ] # FILE1 older than FILE2
[ FILE1 -nt FILE2 ] # FILE1 newer than FILE2
dd if=/dev/zero of=output.dat bs=1024 count=10240
bs
代表 block size,count
代表 block
的个数,bs
乘以 count
就是文件的尺寸。如果希望文件以随机值填充的话可以用
urandom
代替 zero
。
ssh -t remote.host.name screen -x
-t
参数的作用是强制开启虚拟
tty,默认情况下 ssh
如果给出了命令行,则不会在远程机器上开启虚拟
tty,这样会造成无法运行需要与 tty 交互的程序,譬如
screen。
TZ=UTC-8 date # UTC +0800
TZ=UTC+7 date # UTC -0700
TZ
的正负号和时区的正负号相反。
date +%s
date +%s -d "2011-10-01 3:45:07"
TZ=UTC-8 date +%s -d "2011-10-01 3:45:07"
date -d @1317465907
TZ=UTC+8 date -d @1317465907
convert input.jpg -crop 2x1@ +repage output.jpg