Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 通过终端向tsv文件添加头_Bash_Unix - Fatal编程技术网

Bash 通过终端向tsv文件添加头

Bash 通过终端向tsv文件添加头,bash,unix,Bash,Unix,我有许多tsv文件是无头的,我想为每个文件添加相同的头。如何通过终端或bash实现这一点 谢谢 sed -i '1i \here comes header' files 文件可以是glob exp,比如*.txt假设“head”中有header,tsv文件是“body”,那么猫头body|tee body你能解释一下1i的作用吗?行1,执行insert或cat-filein>fileout您需要类似..>fileout和&mv fileout filein的内容来保存“就地”@Kent刚刚学

我有许多tsv文件是无头的,我想为每个文件添加相同的头。如何通过终端或bash实现这一点

谢谢

 sed -i '1i \here comes header' files

文件可以是glob exp,比如
*.txt
假设“head”中有header,tsv文件是“body”,那么
猫头body|tee body

你能解释一下
1i
的作用吗?行
1
,执行
insert
cat-filein>fileout您需要类似
..>fileout和&mv fileout filein
的内容来保存“就地”@Kent刚刚学习了tee命令,非常有趣