0
1
I would like to separate one file into two or three files. (Normally, I open .txt file, check the second column and first, if it has different numbers and copy that data to Input a.txt
)
**1777777;0;**;0;;;l23;;;;;10.07.2011;
**1777777;0;**;0;;;l24;;;;;11.07.2013;
**1777777;1;**;0;;;777;;;;;17.07.2013;
**1777777;1;**;0;;;333;;;;;12.07.2012;
**1888888;1;**;0;;;444;;;;;10.07.2011;
**1888888;1;**;0;;;555;;;;;10.07.2011;
The output should look like the below:
Output: a1.txt
1777777;0;;0;;;l23;;;;;10.07.2011;
1777777;0;;0;;;l24;;;;;11.07.2013;
Output: a2.txt
1777777;1;;0;;;777;;;;;17.07.2013;
1777777;1;;0;;;333;;;;;12.07.2012;
Output: a3.txt
1888888;1;;0;;;444;;;;;10.07.2011;
1888888;1;;0;;;555;;;;;10.07.2011;
awk '/1777777;1;/' a.txt > z1.txt && awk '/1888888;1;/' a.txt > z2.txt I googled a litle bit and solved already. :) – Maris – 2013-11-27T12:09:36.970
awk -F; '$2=="1" {print};' a.txt >z1.txt this is best solution, since awk looks second column and it understands that delimiters are semicols. – Maris – 2013-11-27T15:27:16.303
Please post an answer and accept it, so we know this is already solved. – wingedsubmariner – 2013-11-27T17:01:53.163