Skip to main content
edited tags; edited title
Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117

How to Split File in to Multiple Filessplit file based on #number of Columns in a Linecolumns?

improved formatting
Source Link
steeldriver
  • 83.9k
  • 12
  • 124
  • 175

I have a file containing numeric data. Each line has a varying number of columns. I want to Split the file in to multiple files based on number of columns in a Line. Each Line may have columns varying from 1-10

Below is a sample Input

file.txt 23 53; 34; 31 45 67; 46 78 95; 34 17; 19; 37 65 83;

file.txt
23 53;
34;
31 45 67;
46 78 95;
34 17;
19;
37 65 83;

Target Output

file_1column.txt 34; 19;

file_2column.txt 23 53; 34 17;

file_3column.txt 31 45 67; 46 78 95; 37 65 83;

file_1column.txt
34;
19;

file_2column.txt
23 53;
34 17;

file_3column.txt
31 45 67;
46 78 95;
37 65 83;

I have a file containing numeric data. Each line has a varying number of columns. I want to Split the file in to multiple files based on number of columns in a Line. Each Line may have columns varying from 1-10

Below is a sample Input

file.txt 23 53; 34; 31 45 67; 46 78 95; 34 17; 19; 37 65 83;

Target Output

file_1column.txt 34; 19;

file_2column.txt 23 53; 34 17;

file_3column.txt 31 45 67; 46 78 95; 37 65 83;

I have a file containing numeric data. Each line has a varying number of columns. I want to Split the file in to multiple files based on number of columns in a Line. Each Line may have columns varying from 1-10

Below is a sample Input

file.txt
23 53;
34;
31 45 67;
46 78 95;
34 17;
19;
37 65 83;

Target Output

file_1column.txt
34;
19;

file_2column.txt
23 53;
34 17;

file_3column.txt
31 45 67;
46 78 95;
37 65 83;
Source Link

How to Split File in to Multiple Files based on # of Columns in a Line

I have a file containing numeric data. Each line has a varying number of columns. I want to Split the file in to multiple files based on number of columns in a Line. Each Line may have columns varying from 1-10

Below is a sample Input

file.txt 23 53; 34; 31 45 67; 46 78 95; 34 17; 19; 37 65 83;

Target Output

file_1column.txt 34; 19;

file_2column.txt 23 53; 34 17;

file_3column.txt 31 45 67; 46 78 95; 37 65 83;