Perl Command line for stat

Discussion in 'Perl Misc' started by nos, Oct 7, 2003.

  1. nos

    nos Guest

    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
    nos, Oct 7, 2003
    #1
    1. Advertising

  2. nos

    Thens Guest

    On 7 Oct 2003 10:52:23 -0700
    (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.
    Thens, Oct 7, 2003
    #2
    1. Advertising

  3. 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 -le 'print( (stat shift)[10] )' file
    or
    perl -le 'print +(stat shift)[10]' file


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Oct 7, 2003
    #3
  4. On Tue, 7 Oct 2003 23:57:13 +0530, Thens <> wrote:

    >On 7 Oct 2003 10:52:23 -0700
    > (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
    --
    # This prints: Just another Perl hacker,
    seek DATA,15,0 and print q... <DATA>;
    __END__
    Michele Dondi, Oct 9, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven T. Hatton
    Replies:
    3
    Views:
    9,705
    Pete Becker
    Jun 2, 2005
  2. Patrick Useldinger

    os.stat('<filename>')[stat.ST_INO] on Windows

    Patrick Useldinger, Feb 27, 2005, in forum: Python
    Replies:
    6
    Views:
    1,170
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Mar 3, 2005
  3. Magesh
    Replies:
    3
    Views:
    444
    Gordon Burditt
    Oct 5, 2007
  4. Rolf Krüger
    Replies:
    2
    Views:
    614
    Ian Collins
    Mar 12, 2008
  5. ruck
    Replies:
    10
    Views:
    1,273
Loading...

Share This Page