Create this program, say largesplitter.c , and use the command
zcat large_file.gz | largesplitter
Unpainted program:
#include <errno.h> #include <stdio.h> #include <string.h> int main (void) { char buf [32000]; // todo: resize this if the second field is larger than char cmd [120]; long linenum = 0; while (fgets (buf, sizeof buf, stdin)) { ++linenum; char *cp = strchr (buf, '\t'); // identify first field delimited by tab if (!cp) { fprintf (stderr, "line %d missing delimiter\n", linenum); continue; } *cp = '\000'; // split line FILE *out = fopen (buf, "w"); if (!out) { fprintf (stderr, "error creating '%s': %s\n", buf, strerror(errno)); continue; } fprintf (out, "%s", cp+1); fclose (out); snprintf (cmd, sizeof cmd, "gzip %s", buf); system (cmd); } return 0; }
This compiles without errors on my system, but I have not tested its functionality.
source share