NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: geting some file stat
On Tue, 2008-02-19 at 23:39 +0100, Johnny Billquist wrote:
> Aleksey Cheusov skrev:
> >> Thanks all for your help,
> >
> >> indeed
> >> stat -f "%Mp%Lp:%u:%g:%N"
> >> does the trick
> >
> >> On Tue, Feb 19, 2008 at 02:26:10PM -0600, Robby Griffin wrote:
> > >> Don't forget you can stat multiple files, too:
> > >>
> > >> stat -f "%N %u %g %Mp%Lp" filename1 filename2 ...
> >
> >> but I have a *large* number of files.. and would expect a shell error
> >> using them all on one line...
> >
> > cat file_list.txt | xargs stat -f "%N %u %g %Mp%Lp"
>
> And of course that *will* be a problem if he has a large number of files,
> since
> there are limits on how long lines are acceptable...
No there won't be a problem with a large number of files. Xargs knows
how to handle these things. It uses the sysconf _SC_ARG_MAX to set a
maximum buffer allowed for the command + arguments. If you want to set
it to something smaller, you can specify it on the commandline with -s
<size>.
# wc /usr/share/dict/words
234976 234976 2487217 /usr/share/dict/words
# cat /usr/share/dict/words | xargs echo | wc -l
47
xargs split the input into 47 different commands.
> xargs causes the same deal, and have the same limit as the shell itself. You
> pass a large line to the stat program.
>
> If indeed the number of files are so large that this is a problem, then he
> needs
> to process the files fewer at a time.
> There are several ways to go about doing that. Putting the result in a file,
> and
> then split the file, and go through each piece independently for instance, or
> use find in a more creative way...
>
> Johnny
>
Home |
Main Index |
Thread Index |
Old Index