Question: (Closed) split text file in multiples text files
0
gravatar for ulises.rodriguez
10 weeks ago by
ulises.rodriguez0 wrote:

Hello, I Have a file text that looks like this

number1.1   characters_string_1
number1.2   characters_string_2
number1.3   characters_string_3

number2.1   characters_string_1
number2.2   characters_string_2
number2.3   characters_string_3

number3.1   characters_string_1
number3.2   characters_string_2
number3.3   characters_string_3

and I would like to split this text file in multiple text files

sequence • 237 views
ADD COMMENTlink modified 10 weeks ago by anicet.ebou130 • written 10 weeks ago by ulises.rodriguez0
1

How about

man split

?

ADD REPLYlink written 10 weeks ago by 5heikki7.5k
1

Your question needs a lot more information. In addition, it is not obvious how this is related to bioinformatics, which is required on Biostars. Please update your question and elaborate.

ADD REPLYlink written 10 weeks ago by WouterDeCoster31k
1

What is the expected output for this file? 3 files based on blank rows? or 3 files based on first column? Please clarify.

ADD REPLYlink written 10 weeks ago by zx87544.8k

how do expect your 'multiple text files' to look like? Each line one file? Each column one file? There are so many options...

ADD REPLYlink written 10 weeks ago by Carambakaracho450

if you want to save each line into a separate file,

cat file.txt | while read line; do echo $line > $line.txt ; done
ADD REPLYlink written 10 weeks ago by mbk0asis360
1

Just a minor comment, but this will probably lead to unpleasant file names, especially since the OPs file has white space.

ADD REPLYlink written 10 weeks ago by jrj.healey6.0k

Hello ulises.rodriguez!

We believe that this post does not fit the main topic of this site.

Please tell us how this is related to bioinformatics.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ADD REPLYlink written 10 weeks ago by Ram17k
0
gravatar for anicet.ebou
10 weeks ago by
anicet.ebou130
anicet.ebou130 wrote:

With a one-line bash script:

awk -v RS= '{print > ("output-" NR ".txt")}' file_name

ADD COMMENTlink written 10 weeks ago by anicet.ebou130
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

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