-
-
Save jishanshaikh4/c43677d42aecf23b52591de6ec4294a0 to your computer and use it in GitHub Desktop.
Split a 12 MB text file into 12 separate text files with index (awk)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk '{ | |
a[NR] = $0 | |
} | |
END { | |
for (i = 1; i in a; ++i) { | |
x = (i * 12 - 1) / NR + 1 | |
sub(/\..*$/, "", x) | |
print a[i] > "file" x ".txt" | |
} | |
}' file.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment