0

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;
Gaff
  • 18,569
  • 15
  • 57
  • 68
Maris
  • 63
  • 1
  • 8
  • awk '/1777777;1;/' a.txt > z1.txt && awk '/1888888;1;/' a.txt > z2.txt I googled a litle bit and solved already. :) – Maris Nov 27 '13 at 12:09
  • 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 Nov 27 '13 at 15:27
  • Please post an answer and accept it, so we know this is already solved. – wingedsubmariner Nov 27 '13 at 17:01

0 Answers0