10
1
dog
is a command-line utility that takes in an arbitrary number of arguments,
the first of which is the text to be written and the others are arbitrarily many files.
The dog
utility will split the text in equal portions over these files. If there is a remainder n
, the first n
files get an additional byte
dog
is the opposite of cat
, as such, forall x
, the following should hold.
$> dog x a.txt b.txt ...
$> cat a.txt b.txt ...
x$>
Where ...
indicates arbitrarily many files.
An example (12 bytes, 3 files, can be split evenly):
$> ./dog.py "Dogs vs Cats" a.txt b.txt c.txt
$> cat a.txt
Dogs$> cat b.txt
vs $> cat c.txt
Cats$> cat a.txt b.txt c.txt
Dogs vs Cats$>
An example with remainder (13 bytes, 5 files, remainder 3):
9$>./dog.py "0123456789abc" a.txt b.txt c.txt d.txt e.txt
$> cat a.txt
012$> cat b.txt
345$> cat c.txt
678$> cat d.txt
9a$> cat e.txt
bc$> cat a.txt b.txt c.txt d.txt e.txt
0123456789abc$>
It's implied, but just to double check: 1) Do the arguments have to come in via command line? 2) Do we always have to output to files? – Sp3000 – 2015-10-05T12:35:35.013
@Sp3000 yes, to 1 and 2 – Caridorc – 2015-10-05T12:47:23.533
It would be more "unixy" for the input string to come from STDIN. But that's your call... – Digital Trauma – 2015-10-05T18:01:09.597
1@DigitalTrauma there's already an answer, I would feel bad for invalidating it by a rule change – Caridorc – 2015-10-05T18:06:29.317
2I've been learning about some oddly-named UNIX utilities from this site lately (tac, dog, ...). – kirbyfan64sos – 2015-10-06T14:08:37.143
@kirbyfan64sos They are non-existent, they are just word-puns over the cat util – Caridorc – 2015-10-06T14:13:36.407
Yeah, I know, but they're still weird, and I wouldn't be surprised if someone has actually named tools like that before. – kirbyfan64sos – 2015-10-06T14:14:23.303
1
@kirbyfan64sos and Caridorc:
– DLosc – 2015-10-06T14:30:22.900tac
is real.@DLosc funny,
tac
is an x-ray medical exam in Italian. I think it is just a coincidence though – Caridorc – 2015-10-06T14:33:09.603@Caridorc Apparently the 'tac' scan is the language word order for a 'cat' scan in English (which is a special type of X-ray scan). The Xray (or at least what Americans would consider an X-ray - where you put up a static flat image) is raggi X. Oh, the joys that the 'other languages' sidebar on Wikipedia can bring. – None – 2015-10-07T21:19:30.597
I like the idea of *equal portions over these files* with at least 1 byte len as maximum difference! – F. Hauri – 2016-05-13T20:20:53.097