I am trying to use the text of one file as a text file name with and the text of another as the contents of that text file. Is this possible? Thank you :).
For example, in the two files attached, target.txt has:
1.txt
2.txt
and out_parse.txt has:
13 20763642 20763642 C G
13 20763438 20763438 C G
What I can not seem to do is use the first line of target.txt as the text file name and combine it with the first line of out_parse.txt and so on for the second.
Desired output:
1.txt
13 20763642 20763642 C G
2.txt
13 20763438 20763438 C G
Thank you :).
Try:
awk '{close(fname)} (getline fname<f)>0 {print>fname}' f=target.txt out_parse.txt
1 Like
$
$ paste -d: target.txt out_parse.txt | sed -e 's/:/\n/' -e 's/$/\n/'
1.txt
13 20763642 20763642 C G
2.txt
13 20763438 20763438 C G
$
$
1 Like
Note that the results of durden_tyler's solution and mine differ a lot, because of ambiguity in your requirements.
I read it so that the output would produce 2 different files with the file names specified in the target file, each with one line from the out_parse file
durden_tyler's output produces one file with both the input and the file names...
To avoid this kind of confusion, you need to put more effort still in specifying your requirements..
----
Note: only GNU sed supports \n
in the replacement part of the s
function.
Thank you for the clarification and I apologize for the ambiguity... I will put for more effort in being more specific. Thank you :).