Question: How to get one output file containing processed data from several files and each filename used as header followed by the data
0
gravatar for prasoon.agarwal
2.6 years ago by
prasoon.agarwal10 wrote:

I am running samtools on multiple files (2500 files) so using the following command

sed '1d' Chromosome_cord_new.txt | xargs -P 4 -I % sh -c "samtools idxstats *.bam % > %.txt"

this gives me different file with the names of each coordinate.txt. I want to run this command in a way that inspite of getting so many output files in my case 2500 files, how can I get only one output file with each filename as header follwed by the output data of that file. So I am getting coordinate 1.txt, coordinate 2.txt ...... and so on as output but I want to get output in one file like coordinate 1 output data coordinate 2 outputdata ..... and so on

I have 2500 coordinates in this way. I want to plot the data points from each coordinates afterwards which will be easier if all data is contained in one file rather than in 2500 files separately.

Please suggest something.

Thanks

shell • 901 views
ADD COMMENTlink modified 2.5 years ago by ole.tange3.3k • written 2.6 years ago by prasoon.agarwal10
1
gravatar for venu
2.6 years ago by
venu5.7k
Germany
venu5.7k wrote:

Using a for loop

for i in *.txt; do echo "$i" >> new_file.txt ; cat $i >> new_file.txt; done
ADD COMMENTlink written 2.6 years ago by venu5.7k

Thanks venu your suggestion are quite good.

ADD REPLYlink written 2.6 years ago by prasoon.agarwal10
0
gravatar for robertwalker309
2.5 years ago by
New York
robertwalker3090 wrote:

Get the output with for i in *.txt; do echo "$i" >> new_file.txt ; cat $i >> new_file.txt; the ink. To read more go to my link Generic Viagra

ADD COMMENTlink written 2.5 years ago by robertwalker3090
1

F*cking bad spammer.

ADD REPLYlink written 2.5 years ago by ole.tange3.3k
0
gravatar for ole.tange
2.5 years ago by
ole.tange3.3k
Denmark
ole.tange3.3k wrote:
parallel 'echo {}; cat {}' ::: *.txt > newfile
ADD COMMENTlink written 2.5 years ago by ole.tange3.3k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1563 users visited in the last hour