'Bash for file parsing every nth occurance with a structured file having fix pattern
I have a big file with start pattern END at every instance (a snapshots), How do I write new file that can write at every nth instance. e.g. every 2nd snap [1,3,5,..] or every 25th snap [1, 25, 50, 75, 100, ..] with file having snapshots [1,2,3,4,5...1000] with following example pattern.
example:
END
qweqweq
qweqweq
qweqwe
END
typowoeri
ertpoietp
operitope
END
retorter
erteteert
ewrtert
I want
END
qweqweq
qweqweq
qweqwe
END
retorter
erteteert
ewrtert
awk '/END/{i++}{print > "file."i}' file
I used above code to split the file into individual files. I have 3 snaps, and I am able get 3 individual files. But I want a single file with every 2nd snap in it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
