我正在尝试将几个文件合并为一个,在第一列中添加每个文件的名称。我已经放置了标题和文件名,但是我不希望整个文件名 谢谢
#!/bin/sh
for i in *.txt
do
head -1 $i | awk '{OFS="\t";print "Sample", $0}' > outputprueba.txt
break
done
for a in *bla.txt
do
sed 1d $a | awk -v x="'"$a"'" '{OFS="\t";print x, $0}' >> outputprueba.txt
done
I expect this output:
Sample Chr Start End
File1 chr1 10318652 10318652
File1 chr1 10322054 10322054
File2 chr1 132887500 132887500
File2 chr1 132888208 132888208
but the actual output is:
Sample Chr Start End
'File1_annotated_fastq_blablabla.txt' chr1 10318652 10318652
'File1_annotated_fastq_blablabla.txt' chr1 10322054 10322054
'File2_annotated_fastq_blablabla.txt' chr1 132887500 132887500
'File2_annotated_fastq_blablabla.txt' chr1 132888208 132888208
答案 0 :(得分:0)
这可能是您想要的:
readFiles