How to combine multiple text files of different lengths and multiple columns by a column The Next CEO of Stack OverflowUsing text list to batch-rename filesNeeded simple script/loop/command for input command, execute and output within textfilesHow to combine multiple text files into one text file ordered by date created?Remove duplicated from two files and merge the unique onesDownloading email messages as text files (multiple accounts) from command lineMorge text files from CLI with sort order and rootReplacing text in multiple files with text from a list in orderCollate all data from each .txt file into one results fileRemove all non-numeric characters from text filesawk: pipe output of (conditional) print to gzip
Prodigo = pro + ago?
What is the difference between 'contrib' and 'non-free' packages repositories?
Is it reasonable to ask other researchers to send me their previous grant applications?
Is it a bad idea to plug the other end of ESD strap to wall ground?
Which acid/base does a strong base/acid react when added to a buffer solution?
Is it OK to decorate a log book cover?
Is there a rule of thumb for determining the amount one should accept for a settlement offer?
How seriously should I take size and weight limits of hand luggage?
Can I hook these wires up to find the connection to a dead outlet?
Early programmable calculators with RS-232
Upgrading From a 9 Speed Sora Derailleur?
Is it "common practice in Fourier transform spectroscopy to multiply the measured interferogram by an apodizing function"? If so, why?
Oldie but Goldie
What did the word "leisure" mean in late 18th Century usage?
How did scripture get the name bible?
Is a distribution that is normal, but highly skewed, considered Gaussian?
How to coordinate airplane tickets?
How can the PCs determine if an item is a phylactery?
Gödel's incompleteness theorems - what are the religious implications?
Find a path from s to t using as few red nodes as possible
Planeswalker Ability and Death Timing
Identify and count spells (Distinctive events within each group)
Why does the freezing point matter when picking cooler ice packs?
Could a dragon use its wings to swim?
How to combine multiple text files of different lengths and multiple columns by a column
The Next CEO of Stack OverflowUsing text list to batch-rename filesNeeded simple script/loop/command for input command, execute and output within textfilesHow to combine multiple text files into one text file ordered by date created?Remove duplicated from two files and merge the unique onesDownloading email messages as text files (multiple accounts) from command lineMorge text files from CLI with sort order and rootReplacing text in multiple files with text from a list in orderCollate all data from each .txt file into one results fileRemove all non-numeric characters from text filesawk: pipe output of (conditional) print to gzip
I have 60 text files of different lengths and same column names.
For example:
cat Sample_145_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
19258 circRNA
612 ciRNA
cat Sample_146_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
17791 circRNA
729 ciRNA
cat Sample_147_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
22838 circRNA
686 ciRNA
cat Sample_148_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
19404 circRNA
475 ciRNA
I want to produce a 'master' table of all identified circRNAs
, with readnumber
as column for each sample and flankintron
as rownames:
command-line
New contributor
add a comment |
I have 60 text files of different lengths and same column names.
For example:
cat Sample_145_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
19258 circRNA
612 ciRNA
cat Sample_146_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
17791 circRNA
729 ciRNA
cat Sample_147_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
22838 circRNA
686 ciRNA
cat Sample_148_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
19404 circRNA
475 ciRNA
I want to produce a 'master' table of all identified circRNAs
, with readnumber
as column for each sample and flankintron
as rownames:
command-line
New contributor
add a comment |
I have 60 text files of different lengths and same column names.
For example:
cat Sample_145_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
19258 circRNA
612 ciRNA
cat Sample_146_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
17791 circRNA
729 ciRNA
cat Sample_147_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
22838 circRNA
686 ciRNA
cat Sample_148_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
19404 circRNA
475 ciRNA
I want to produce a 'master' table of all identified circRNAs
, with readnumber
as column for each sample and flankintron
as rownames:
command-line
New contributor
I have 60 text files of different lengths and same column names.
For example:
cat Sample_145_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
19258 circRNA
612 ciRNA
cat Sample_146_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
17791 circRNA
729 ciRNA
cat Sample_147_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
22838 circRNA
686 ciRNA
cat Sample_148_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk 'print $14' | sort | uniq -c
19404 circRNA
475 ciRNA
I want to produce a 'master' table of all identified circRNAs
, with readnumber
as column for each sample and flankintron
as rownames:
command-line
command-line
New contributor
New contributor
edited Mar 26 at 22:30
dessert
25.3k673107
25.3k673107
New contributor
asked Mar 26 at 20:14
grtgrt
161
161
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If all of the columns in all of the files are in the same order, then just concat them together with >>
:
for x in 1..60; do
# These flags for tail just cut of the top line, which is your headers
tail -n 2 Sample_$x_blah.txt >> Sample_master.txt
# and the double carat makes the output append^
done
If not, then you can write the translations in awk
sort of like you had above, i.e.
$ cat Sample_1.txt
col1,col2,col3,col4 #etc
$ cat Sample_2.txt
col4,col3,col2,col1
$ cat Sample_1.txt > Sample_Master.txt # no translation needed
$ awk 'print $4","$3","$2","$1 ' Sample_2.txt >> Sample_Master.txt
But with 60 files, that would be more work than- something like writing a python script using python's csv lib...
add a comment |
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
grt is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1128946%2fhow-to-combine-multiple-text-files-of-different-lengths-and-multiple-columns-by%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If all of the columns in all of the files are in the same order, then just concat them together with >>
:
for x in 1..60; do
# These flags for tail just cut of the top line, which is your headers
tail -n 2 Sample_$x_blah.txt >> Sample_master.txt
# and the double carat makes the output append^
done
If not, then you can write the translations in awk
sort of like you had above, i.e.
$ cat Sample_1.txt
col1,col2,col3,col4 #etc
$ cat Sample_2.txt
col4,col3,col2,col1
$ cat Sample_1.txt > Sample_Master.txt # no translation needed
$ awk 'print $4","$3","$2","$1 ' Sample_2.txt >> Sample_Master.txt
But with 60 files, that would be more work than- something like writing a python script using python's csv lib...
add a comment |
If all of the columns in all of the files are in the same order, then just concat them together with >>
:
for x in 1..60; do
# These flags for tail just cut of the top line, which is your headers
tail -n 2 Sample_$x_blah.txt >> Sample_master.txt
# and the double carat makes the output append^
done
If not, then you can write the translations in awk
sort of like you had above, i.e.
$ cat Sample_1.txt
col1,col2,col3,col4 #etc
$ cat Sample_2.txt
col4,col3,col2,col1
$ cat Sample_1.txt > Sample_Master.txt # no translation needed
$ awk 'print $4","$3","$2","$1 ' Sample_2.txt >> Sample_Master.txt
But with 60 files, that would be more work than- something like writing a python script using python's csv lib...
add a comment |
If all of the columns in all of the files are in the same order, then just concat them together with >>
:
for x in 1..60; do
# These flags for tail just cut of the top line, which is your headers
tail -n 2 Sample_$x_blah.txt >> Sample_master.txt
# and the double carat makes the output append^
done
If not, then you can write the translations in awk
sort of like you had above, i.e.
$ cat Sample_1.txt
col1,col2,col3,col4 #etc
$ cat Sample_2.txt
col4,col3,col2,col1
$ cat Sample_1.txt > Sample_Master.txt # no translation needed
$ awk 'print $4","$3","$2","$1 ' Sample_2.txt >> Sample_Master.txt
But with 60 files, that would be more work than- something like writing a python script using python's csv lib...
If all of the columns in all of the files are in the same order, then just concat them together with >>
:
for x in 1..60; do
# These flags for tail just cut of the top line, which is your headers
tail -n 2 Sample_$x_blah.txt >> Sample_master.txt
# and the double carat makes the output append^
done
If not, then you can write the translations in awk
sort of like you had above, i.e.
$ cat Sample_1.txt
col1,col2,col3,col4 #etc
$ cat Sample_2.txt
col4,col3,col2,col1
$ cat Sample_1.txt > Sample_Master.txt # no translation needed
$ awk 'print $4","$3","$2","$1 ' Sample_2.txt >> Sample_Master.txt
But with 60 files, that would be more work than- something like writing a python script using python's csv lib...
edited Mar 26 at 22:34
dessert
25.3k673107
25.3k673107
answered Mar 26 at 20:43
rm-vandarm-vanda
2,35321423
2,35321423
add a comment |
add a comment |
grt is a new contributor. Be nice, and check out our Code of Conduct.
grt is a new contributor. Be nice, and check out our Code of Conduct.
grt is a new contributor. Be nice, and check out our Code of Conduct.
grt is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1128946%2fhow-to-combine-multiple-text-files-of-different-lengths-and-multiple-columns-by%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown