I have a log.txt file which contains 20k lines. Each line having numbers and there xyz plane coordinates and they are separated by sets. Sets can be identify by there names as ABC_1, ABC_2 and so on in the log.txt
From this log.txt file I want to segregate all sets data in to individual Text files, which should contain all data from set (eg. ABC_1).
My log.txt looks like below.
ABC_1:
1, (xyz coordinates)
2, (xyz coordinates)
3, (xyz coordinates)
.... Continue
ABC_2:
101, (xyz coordinates)
102, (xyz coordinates)
103, (xyz coordinates)
.... Continue
ABC_3:
201, (xyz coordinates)
202, (xyz coordinates)
203, (xyz coordinates)
.... Continue
ABC_99:
9991, (xyz coordinates)
9992, (xyz coordinates)
9993, (xyz coordinates)
.... Continue
I want to create a script which can give me 99 individual text files from a single log.txt file and which should be named as set name ABC_1.TXT
, ABC_2.TXT
... to ABC_99.TXT
from log.txt.
awk '/^ABC_/{N++;next} {print >"ABC_"N".txt"}' infile
(assuming the bocks are sorted with#
inABC_#
otherwiseawk -F: '/^ABC_/{fname=$1".txt";next} {print >fname}' infile
) and that you can find in the answer in flagged question except you no need paste them which you can ignore it? – αғsнιη May 06 '18 at 08:25