一般用head -n -1 urfile
比sed "$d" file要快
这个好像是非常快的解决方法
:|dd of=urfile seek=1 bs=$(($(find urfile -printf "%s")-$(tail -1 urfile|wc -c)))
or
:|dd of=urfile seek=1 bs=$(($(stat -c%s urfile)-$(tail -1 urfile|wc -c)))
这条命令:的输出就是输入文件。
: No effect; the command does nothing. A zero exit code
is returned.意思就是啥也没干
后面的才是重点,用来truncate文件
of=file
Specifies the output path. Standard output is the
default. If the seek=expr conversion is not also
specified, the output file will be truncated before
the copy begins, unless conv=notrunc is specified. If
seek=expr is specified, but conv=notrunc is not, the
effect of the copy will be to preserve the blocks in
the output file over which dd seeks, but no other por-
tion of the output file will be preserved. (If the
size of the seek plus the size of the input file is
less than the previous size of the output file, the
output file is shortened by the copy.)
就是指直接在原文件上做改动
当没有指定conv=notrunc时候,会保留 seek*bloks的大小,这样文件就没有复制操作,直接在源文件上进行改变,这也是它快的原因。真是个NB人想出来的
阅读(1663) | 评论(0) | 转发(0) |