in reply to Perl one liner and stat function
perl -MFile::stat -le'$pv=stat(shift); print "$pv->uid,$pv->gid,$pv->m +ode"' /dir/filename
But it would be shorter to use the indexes:
perl -le'$,=","; print((stat shift)[4,5,2])' /dir/filename
It makes more sense to display the permissions in octal:
perl -e'printf "%s,%s,%04o\n", (stat shift)[4,5,2]' /dir/filename
Finally, to process multiple arguments at once:
perl -e'printf "%s:%s,%s,%04o\n", $_, (stat)[4,5,2] for @ARGV' file1 f +ile2
Update: Oops, the first one won't work because the method calls are in a string literal.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl one liner and stat function
by csarid (Sexton) on Mar 24, 2009 at 00:47 UTC | |
by Anonymous Monk on Mar 24, 2009 at 02:30 UTC |