Delimeters when using the "cut" tool.

Vincent Vladas Juodvalkis juodvalk at ee.eng.ohio-state.edu
Fri Apr 5 04:50:42 AEST 1991


I am trying to write a program in sh that will check a user's quota
before allowing them to use the compress tool.  I have the program
writen and am now in the process of finding the thousand or so errors
that I always manage to code into a fifty line program.

Anyway, I am relatively new to shell programming and am having
dificulty with the cut tool.  What I need to use it for is to get one
integer out of the output I get from the command  "quota -v".  The
output from this command is inconsistant between users so I cannot
just use the collumn feature of cut.  The output from "quota -v" looks
like this...

Disk quotas for juodvalk (uid 2360):
Filesystem     usage  quota  limit    timeleft  files  quota  limit    timeleft
/tmp_mnt/homea
                 972  50000  50500                 33      0      0


I use the line 

`quota -v 2>&1 | grep -v quota | grep -v /`

to get 

                 972  50000  50500                 33      0      0


Now my problem comes when I try to cut this line.  If I just try to
cut it by filed, trying to get the second field (50000), using the
following

quota -v 2>&1 | grep -v quota | grep -v / | cut -f2

the output I get is 

                 972  50000  50500                 33      0      0

Which is the same as before.

The reason that I came up with for this is that the generic delimeter
is a tab, and this seemed to imply that the spaces in the output were
not tabs.  So I tried using spaces as the delimeter.  The code I osed
looked like

quota -v 2>&1 | grep -v quota | grep -v / | cut -d" " -f2

the output I got was just a bank line.  My hypothesis for this is that
the cut cuts after the first space it encounters and returns all that
ir finds until the next space it encounters (which in this case
happens to be the very next character, thus returning a line with
nothing in it).

What I need is either a was to get rid of all the extra spaces, or
maybe just a better way to cut up the lines.


I would appreciate any suggestion.



	Vincent



-------------------------------------------------------------------------------
    Vincent V. Juodvalkis                           "I can still move...
    juodvalk at ee.eng.ohio-state.edu                   I can still drink."
    juodvalk at cis.ohio-state.edu                            -Robert Reed
    The Ohio State University




More information about the Comp.unix.questions mailing list