Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.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
Awk 从不同目录中具有相同名称的多个文件中剪切列并粘贴到一个目录中_Awk_Paste - Fatal编程技术网

Awk 从不同目录中具有相同名称的多个文件中剪切列并粘贴到一个目录中

Awk 从不同目录中具有相同名称的多个文件中剪切列并粘贴到一个目录中,awk,paste,Awk,Paste,我有多个同名3pGtoA_freq.txt的文件,但都位于不同的目录中。 每个文件如下所示: pos 5pG>A 1 0.162421557770395 2 0.0989643268124281 3 0.0804131316857248 4 0.0616563298066399 5 0.0577551761714493 6 0.0582450832072617 7 0.0393129770992366 8 0.037037037037037 9 0.03

我有多个同名3pGtoA_freq.txt的文件,但都位于不同的目录中。 每个文件如下所示:

pos 5pG>A
1   0.162421557770395
2   0.0989643268124281
3   0.0804131316857248
4   0.0616563298066399
5   0.0577551761714493
6   0.0582450832072617
7   0.0393129770992366
8   0.037037037037037
9   0.0301016419077404
10  0.0327510917030568
11  0.0301598837209302
12  0.0309050772626932
13  0.0262089331856774
14  0.0254612546125461
15  0.0226130653266332
16  0.0206971677559913
17  0.0181280059193489
18  0.0243993993993994
19  0.0181347150259067
20  0.0224429727740986
21  0.0175690211545357
22  0.0183916336098089
23  0.0196078431372549
24  0.0187983781791375
25  0.0173192771084337
我想从每个文件中剪切第2列,并在一个文件中逐列粘贴

我试着跑步:

for s in results_Sample_*_hg19/results_MapDamage_Sample_*/results_Sample_*_bwa_LongSeed_sorted_hg19_noPCR/3pGtoA_freq.txt; do awk '{print $2}' $s >> /home/users/istolarek/aDNA/3pGtoA_all; done
但这并不是将列彼此相邻粘贴

我还想用“*”来命名每一列,这是路径中唯一更改的字符串


有什么帮助吗

对于$find you_file_dir中的i-name 3pGtoA_freq.txt;做awk'{print$2>>NewFile}'$i;完成

我会在awk中并行处理所有文件:

awk 'BEGIN{printf "pos ";
           for(i=1;i<ARGC;++i)
             printf "%-19s",gensub("^results_Sample_","",1,gensub("_hg19.*","",1,ARGV[i]));
           printf "\n";
           while(getline<ARGV[1]){
             printf "%-4s%-19s",$1,$2;
             for(i=2;i<ARGC;++i){
               getline<ARGV[i];
               printf "%-19s",$2}
             printf "\n"}}{exit}' \
results_Sample_*_hg19/results_MapDamage_Sample_*/results_Sample_*_bwa_LongSeed_sorted_hg19_noPCR/3pGtoA_freq.txt
如果您的awk没有gensub,我正在使用cygwin,您可以删除前四行printf printf;在这种情况下不会打印标题