Perl Command line for stat

N

nos

I am trying to use a command line Perl –e to stat a file with in
Solaris. I was looking for someone that can modify the line so it
will work from a command line. I have not been able to figure out the
right format to use. Can someone please help me with this.

Perl –e ‘(stat($filename)) [10]' any suggestions
 
T

Thens

On 7 Oct 2003 10:52:23 -0700
(e-mail address removed) (nos) wrote:

# I am trying to use a command line Perl _e to stat a file with in
# Solaris. I was looking for someone that can modify the line so it
# will work from a command line. I have not been able to figure out the
# right format to use. Can someone please help me with this.
#
# Perl _e _(stat($filename)) [10]' any suggestions

perl -e 'print [stat $ARGV[0]]->[10]' <filename>

is what you want.

perldoc perlrun for more information.


Regards,
Thens.
 
T

Tad McClellan

nos said:
I am trying to use a command line Perl –e to stat a file with in
Solaris. I was looking for someone that can modify the line so it
will work from a command line. I have not been able to figure out the
right format to use. Can someone please help me with this.

Perl –e ‘(stat($filename)) [10]' any suggestions


perl -le 'print( (stat shift)[10] )' file
or
perl -le 'print +(stat shift)[10]' file
 
M

Michele Dondi

On 7 Oct 2003 10:52:23 -0700
(e-mail address removed) (nos) wrote:

# I am trying to use a command line Perl _e to stat a file with in
# Solaris. I was looking for someone that can modify the line so it
# will work from a command line. I have not been able to figure out the
# right format to use. Can someone please help me with this.
#
# Perl _e _(stat($filename)) [10]' any suggestions

perl -e 'print [stat $ARGV[0]]->[10]' <filename>

perl -le 'print +(stat shift)[10]' <filename>

or slightly more generic,

perl -le 'print for map +(stat)[10], @ARGV' <filename(s)>

but then maybe better something along the lines of

perl -le 'print for map "$_\t".(stat)[10], @ARGV' <filename(s)>

In any case displaying (stat)[10] sounds strange IMHO: isn't it that
what the OP really wants is something of the kind of

perl -le 'print scalar localtime +(stat shift)[10]' <filename>


Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top