Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Arguments too long with du

1,164 views
Skip to first unread message

Antonio Rodriguez

unread,
Sep 4, 2001, 10:40:39 AM9/4/01
to
When trying to run

/usr/bin/du -k -s /home/e122/*

in a script beginnig with

#!/bin/csh -f

I get the error message "Arguments too long". This error also occurs when
run by hand in csh, but not with other similar lines in the script such as

/usr/bin/du -k -s /home/e86/*

or when run in tcsh. I've tried using "-ks" instead with no change.

Any ideas?

Thanks

Antonio Rodriguez

John Gordon

unread,
Sep 4, 2001, 12:16:21 PM9/4/01
to
Antonio Rodriguez <ant...@eng.fsu.edu> writes:

> /usr/bin/du -k -s /home/e122/*

> I get the error message "Arguments too long". This error also occurs when
> run by hand in csh, but not with other similar lines in the script such as

> /usr/bin/du -k -s /home/e86/*

commands are limited to a maximum total length of text. if a command
includes shell wildcards that expand to a length greater than that
maximum, an error is generated.

there must be more files in /home/e122 than in /home/e86. that's why
you get an error for e122 but not for e86.

anyway, here's one way to solve this problem:

cd to the directory in question and then run "/usr/bin/du -k -s *".
(remember to cd back to the original directory when you're done.)
this reduces the command length by several characters per directory.
the total savings can be large if "*" expands to many directories.

---
"... What with you being his parents and all, I think that you could
be trusted not to shaft him." -- Robert Chang, rec.games.board

John Gordon gor...@osiris.cso.uiuc.edu

those who know me have no need of my name

unread,
Sep 4, 2001, 2:02:40 PM9/4/01
to
<Pine.GSO.4.21.01090...@boomerang.eng.fsu.edu> divulged:

>When trying to run
>
>/usr/bin/du -k -s /home/e122/*
>
>in a script beginnig with
>
>#!/bin/csh -f
>
>I get the error message "Arguments too long".

as mentioned in another response, this happens because you've overflowed
the command line (in essence). what you need to do is to reduce the number
of directories presented to du, which means that du will have to be called
several times.

if you have gnu find and xargs then use them, e.g.,

find /home/e122 -type d -maxdepth 1 -print0 | xargs -0re du -ks

there are plenty of other ways, but if nothing else presents itself you'll
just have to iterate through the list of directories the "hard" way, e.g.,

: i don't do csh, this is bourne shell syntax
ls -1 /home/e122/ | while read dir && [ -n "$dir" ]; do
test -d "/home/e122/$dir" || continue
du -ks "/home/e122/$dir"
done

note: if you have that many directories within one directory your system is
probably spending a lot of time dealing with that; you should consider
adding another level.

--
okay, have a sig then

Ernest N. Mamikonyan

unread,
Sep 5, 2001, 12:13:44 PM9/5/01
to
just do

ls -1 /home/e122 | xargs /usr/bin/du -ks


--
Good Luck!
Ernie (ErnieMa...@netscape.net)

0 new messages