Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi monks,

I have a drive space script (not mine,actually, but we're using it---we don't deserve any credit for it :)) that is running to try to determine user directory usage.

When it runs, it dies on a user's subdir with an apostrophe. I wonder if there is an "if" loop i can put into the following script to either escape the character(s) or to just skip the folder/dir.

here is the script, the error follows:

#!/bin/perl -w # # find big directories in a particular file system # ---- prompt user ---- print "directory> "; $partName="/home/users/"; chomp $partName; # ---- prompt user ---- print "size (in KB)> "; $dirSize="50000"; chomp $dirSize; # ---- find directories ---- @dirs=`find $partName -mount -type d | xargs du -sk`; # ---- print details on large directories ---- for $_ ( @dirs ) { chomp; my($size,$dirname) = split; if ( $size > $dirSize ) { if ( $size > 1000000 ) { # convert to GB $GB=$size/1000000; printf "%8.2f %s %s", $GB, "GB", "$dirname\n"; } elsif ( $size > 1000 ) { # convert to MB $MB=$size/1000; printf "%8.2f %s %s", $MB, "MB", "$dirname\n"; } else { printf "%8.2f %s %s", $size, "KB", "$dirname\n"; } } }

after /home/users is /home/users/0-z..etc/0-z...etc for the first two characters in their username..

xargs: Missing quote: /home/users/b/l/blah/ stuff/webtemp/MP#s
the MP#s in the error actually has a folder named "MP3's"


help would be appreciated....

In reply to drive space script dies on certain characters... by stevenrh

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2023-10-01 05:48 GMT
Find Nodes?
    Voting Booth?

    No recent polls found