PDA

View Full Version : Unix command help.. Jack :)



Stuart
11-03-10, 12:00 PM
I have a script that does stuff to files, but if the files are smaller than 200bytes the script/tool goes bonkers and writes output files till the drive is full.
I want to put in some detection for files smaller than 200bytes (although I believe its only possible to detect less than 512bytes)

I've tried DU -sk name which returns how many 512byte blocks the file occupies, which is fine but I cant seem to get the number of blocks to go into a variable to compare in an if statement..

helps from the g33ks please lol

Iain
11-03-10, 04:34 PM
Bash script? Here's a couple of things to try: http://www.linuxquestions.org/questions/programming-9/file-size-using-bash-script-410766/

Stuart
11-03-10, 04:47 PM
unfortunately I'm using the oldest Unix ever (I think babbage wrote it) and its not got bash on there :(

stat dosent work :( booo

sod it, manual work it is until they pay to get some new shiny in.

Jack
11-03-10, 05:39 PM
Fcuk knows, I haven't even touched a single unix command line for almost 6 months now lol

MK999
11-03-10, 05:44 PM
since we got the serious replies out the way now, have you tried turning it off and on again? lol

Iain
11-03-10, 06:06 PM
Apparently du has argument "-b" which tells you the filesize in bytes.