添加到头部要用 临时文件 。假设临时文件名为 file.tmp 输出文件为file 。echo $a>file.tmpecho $b 若干变量 >>file.tmpcat file>>file.tmprm -f filemv file.tmp file