# split.awk --- do split in awk # # Requires ord() and chr() library functions # # Arnold Robbins, arnold@skeeve.com, Public Domain # May 1993 # Revised slightly, May 2014 # usage: split [-count] [file] [outname] BEGIN { outfile = "x" # default count = 1000 if (ARGC > 4) usage() i = 1 if (i in ARGV && ARGV[i] ~ /^-[[:digit:]]+$/) { count = -ARGV[i] ARGV[i] = "" i++ } # test argv in case reading from stdin instead of file if (i in ARGV) i++ # skip datafile name if (i in ARGV) { outfile = ARGV[i] ARGV[i] = "" } s1 = s2 = "a" out = (outfile s1 s2) } { if (++tcount > count) { close(out) if (s2 == "z") { if (s1 == "z") { printf("split: %s is too large to split\n", FILENAME) > "/dev/stderr" exit 1 } s1 = chr(ord(s1) + 1) s2 = "a" } else s2 = chr(ord(s2) + 1) out = (outfile s1 s2) tcount = 1 } print > out } function usage() { print("usage: split [-num] [file] [outname]") > "/dev/stderr" exit 1 }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
alarm.awk | File | 2.31 KB | 0644 |
|
anagram.awk | File | 1.33 KB | 0644 |
|
awksed.awk | File | 515 B | 0644 |
|
cut.awk | File | 3.61 KB | 0644 |
|
dupword.awk | File | 507 B | 0644 |
|
egrep.awk | File | 1.91 KB | 0644 |
|
extract.awk | File | 1.74 KB | 0644 |
|
guide.awk | File | 165 B | 0644 |
|
histsort.awk | File | 283 B | 0644 |
|
id.awk | File | 1.22 KB | 0644 |
|
igawk.sh | File | 3.11 KB | 0644 |
|
indirectcall.awk | File | 952 B | 0644 |
|
labels.awk | File | 1014 B | 0644 |
|
split.awk | File | 1.17 KB | 0644 |
|
tee.awk | File | 770 B | 0644 |
|
testbits.awk | File | 729 B | 0644 |
|
translate.awk | File | 1.15 KB | 0644 |
|
uniq.awk | File | 2.64 KB | 0644 |
|
wc.awk | File | 1.45 KB | 0644 |
|
wordfreq.awk | File | 347 B | 0644 |
|