O comando split
Colaboração: Rubens Queiroz de Almeida
Data de Publicação: 18 de Junho de 1997
Muitas vezes precisamos dividir um arquivo em vários outros menores,
seguindo alguma convenção. Para isto podemos usar tanto o comando split.
O comando split nos permite dividir um arquivo baseando-se no número
de linhas ou número de bytes que cada arquivo novo deve conter.
% split -l 10 /etc/passwd
Este comando criará vários arquivos denominados xaa, xab, xac, etc.
Nem sempre estes nomes são os mais convenientes. Neste caso podemos,
com o acréscimo de mais um parâmetro, determinar o sufixo do nome dos
arquivos que serão criados:
% split -l 10 /etc/passwd pas-
pas-aa pas-ab pas-ac pas-ad pas-ae pas-af pas-ag pas-ah
Os arquivos criados passaram a conter o prefixo "pas-", permitindo
identificar mais claramente os contadores dos arquivos (aa, ab, ac, etc.)
Além do particionamento em linhas, o comando split, quando invocado com a
opção "b", irá efetuar a divisão do arquivo baseando-se no número de bytes:
% split -b 32k /etc/passwd pas-
% split -b 32 /etc/passwd pas-
% split -b 32m /etc/passwd pas-
No primeiro exemplo, o arquivo /etc/passwd será dividido em vários arquivos
de 32kbytes cada um, ao passo que no segundo exemplo, o arquivo será dividido
em arquivos de 32 bytes cada. No terceiro exemplo, o arquivo /etc/passwd
é dividido em arquivos de 32MB cada (pouco provável :-)
Dica Humorística :-)
BASTARD OPERATOR FROM HELL #12
I get to work and I'm a bit tired so I plug a thick hunk of copper across
the three phase supply and throw the switch. The room is plunged into
darkness as the circuit breakers trip and for once the machine room is silent.
I like it.
I pop the phone off the hook and close the curtains on the observation window.
Now it's *really* dark in there. I wouldn't be surprised if someone had an
accident in here..
I lift a couple of floor tiles up in the darkness and call our maintenance
contractors saying the mini popped the breaker again, then replace the fuses
in it with a couple of nails and short the power supply to ground. You can't
just hope for this sort of thing, you've got to MAKE it happen.
15 minutes later the engineer arives and falls down the hole. I pop the floor
tiles back on just as the System Manager (a new and very thorough individual)
comes in, telling me to watch out, someone could really hurt themselves in the
I nod & tell him that we can't really afford all the downtime, and should I
just throw the breaker and hope that there was no major fault. After thinking
about the negative publicity we're getting already, he makes the last decision
of his short career and tells me to go ahead.
Later, when the smoke clears I examine the smoking remains of the mini. Not
a pretty sight...
"Strange that the breaker jammed shut, isn't it?" I say to our manager as he
packs up the personal things in his office. "One in a million chance. A pity
that someone saw what you did and posted the whole story to comp.misc. You'll
be lucky to get a job managing a car computer after all that publicity..."
I go back to the machine room and throw the rest of the breakers to liven
everything up, then login and start deleting users' email. I spot an
interesting off-the-record sexual proposition from our male consultant to a
member of the men's swim team which will make a good motd, so I copy it there,
modify root's owner name to be "Winker" and password to be "ljkadlkajflkj"
(then call the big boss to report a suspected intrusion). Should be at least
a couple of hours of login time before we can sort that out. In the meantime,
people are just going to have to read that message...
I realise the message has been read when I hear the gunshot from behind the
consultant's closed door.
I edit the online helpdesk information and change the phone number to the
System Manager's - he'll probably appreciate the extra calls at such a sad
I hear another shot and realise he won't be answering any calls today.
I put the phone back on the hook and flip today's excuse card. "Poor power
conditioning". Too plausible. "STATIC BUILDUP". Still a bit too plausible
for my liking, but I don't want to run out of cards before the end of the
year, so I decide to run with it.
The phone rings almost as soon as I've got "Top Gun" in the video machine so
I pause the video and put the phone on hands-free.
"I think I've bought a bad floppy disk"
"Yes?" I wonder if I've suddenly become the consumer's watchdog?
"Well, I've got this disk and it won't format. All the others in the box did
so I thought I must have a bad disk"
"Why are you calling me about this?" I ask
"Well, the disk says guaranteed; where do I go to get a replacement?"
Ah! Of course.
"Well, let's see. Are you sure it's the disk, and not just some problem with
"Static Buildup, you know, static electricity that's passed from you to the
"But I'm wearing a wrist strap!"
Around about now I realise I'm deep in dweeb country. Wrist straps aren't
fashion accessories in my part of town...
"Of course you are, but your average wrist strap has a 1 meg resistor in
series with it, a *really* poor earth. What you need is a direct earth
connection. Hang onto the frame of something that's earthed properly."
"What, you mean like our stainless steel bench?"
"Excellent. Now, have you got a paper clip to discharge the static with?"
"Hang on. Yeah"
"Ok, with your other hand, poke the clip thru the ventilation holes at the back
of the unit, and just touch the contact at the end of the thick red wire."
"The one going to the power supply?"
"Yep, that's it"
"....Hey, isn't that the li... kzzzzt!< >clunk<"
Another call solved by the helpdesk from hell...
<spt (a) grace waikato ac nz>