https://linux.cn/article-8024-1.html#comment
通过重定向到不存在的事物到文件中
> a.txt
使用true命令来重定向到文件
true > a.txt 或者:>a.txt
等同于shell,内置命令,true不进行任何操作,即true的输出结果为空重定向到a.txt
dd,cp,cat 命令结合/dev/null
cp /dev/null a.txt
dd if=/dev/null of=a.txt
cat /dev/null > a.txt
使用echo命令
echo abc > a.txt 为4个字节,默认会添加个\n
echo -n > a.txt
truncate命令
truncate -s 0 a.txt
转载于:https://blog.51cto.com/12218412/1881407