Ask a Question related to Debian, Design and Development.

  1. #1

    Default stat question

    Hello,

    A while ago someone suggested using the stat command to get modification
    times for files etc, ls -al will give the info but I would have to do a
    lot of string stripping etc ...

    I have looked up man "stat", confusing ... googled for it, confusing !
    It is not a regular command, ie "stat" on the command line is a no go
    though there is a man page for it.

    It appears to be a "pearl" module ?

    OK simple question. In a bash script can I use stat to get modification
    times of files ?
    If so what is the syntax ?

    Dave


    --
    To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
    with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
    David selby Guest

  2. Similar Questions and Discussions

    1. Help! I need to know how to use a cookie stat!
      Hey guys I am currently making my first dynamic website and am using the most recent version of Macromedia Studio. the site is almost done but I...
    2. About stat problem ??
      Dear all I found that stat command problems, when the file is over 2GB , it cannot return any result when i use stat command. The following are...
    3. Could not stat error message
      Joe Burns typed (on Mon, Aug 11, 2003 at 09:43:38PM -0400): | I am trying to create a "tar" output file of the "/usr2" filesystem into a | storage...
    4. lsof & non-stat()-ble NFS server
      Hello, We're getting errors in /var/adm/messages saying that an NFS directory is not writable: Jul 17 09:04:33 XXXXXXX nfs: NFS write error...
    5. File.stat.blksize returns nil and not 0 on win2k
      Hello, on the 1.8.0 ruby version of the pragprog installer, File.stat(file).blksize returns nil and not 0 on a windows 2k machine. According to...
  3. #2

    Default Re: stat question

    Frankly I don't see your problem

    helios@kafka:~$ whereis stat
    stat: /usr/bin/stat /usr/share/man/man1/stat.1.gz
    /usr/share/man/man2/stat.2.gz
    helios@kafka:~$ dpkg -S /usr/bin/stat
    coreutils: /usr/bin/stat
    helios@kafka:~$ stat workdir/
    File: `workdir/'
    Size: 4096 Blocks: 8 IO Block: 8192 directory
    Device: 304h/772d Inode: 671748 Links: 4
    Access: (0755/drwxr-xr-x) Uid: ( 1000/ helios) Gid: ( 1000/ helios)
    Access: 2003-08-02 08:55:49.000000000 +0200
    Modify: 2003-07-21 16:14:04.000000000 +0200
    Change: 2003-07-21 16:14:04.000000000 +0200

    -> only the date
    helios@kafka:~$ stat -c %y workdir/
    2003-07-21 16:14:04.000000000 +0200

    -> modification in seconds after the epoch
    helios@kafka:~$ stat -c %Y workdir/
    1058796844

    Can you be more specific about _what_ you actually want ?

    hth
    Elie De Brauwer

    On Saturday 02 August 2003 10:07, David selby wrote:
    > Hello,
    >
    > A while ago someone suggested using the stat command to get modification
    > times for files etc, ls -al will give the info but I would have to do a
    > lot of string stripping etc ...
    >
    > I have looked up man "stat", confusing ... googled for it, confusing !
    > It is not a regular command, ie "stat" on the command line is a no go
    > though there is a man page for it.
    >
    > It appears to be a "pearl" module ?
    >
    > OK simple question. In a bash script can I use stat to get modification
    > times of files ?
    > If so what is the syntax ?
    >
    > Dave

    --
    To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
    with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
    Elie De Brauwer Guest

  4. #3

    Default Re: stat question

    On Sat, Aug 02, 2003 at 09:07:26AM +0100, David selby wrote:
    > A while ago someone suggested using the stat command to get modification
    > times for files etc, ls -al will give the info but I would have to do a
    > lot of string stripping etc ...
    >
    > I have looked up man "stat", confusing ... googled for it, confusing !
    > It is not a regular command, ie "stat" on the command line is a no go
    > though there is a man page for it.
    In woody, you need the 'stat' package. In sarge and sid it's part of
    coreutils, which everyone has installed. You can use
    [url]http://packages.debian.org/[/url] to answer questions like this.

    The reason your searches were confusing is that there's also a system
    call called stat(), which C programmers care about but which isn't
    useful on the command line.
    > It appears to be a "pearl" module ?
    It's called 'perl', not 'pearl' :-) And no, while there may be a Perl
    module with a similar name it's probably not what your respondent was
    referring to.
    > OK simple question. In a bash script can I use stat to get modification
    > times of files ?
    > If so what is the syntax ?
    'stat' is a bit tedious for this, because you'd have to parse it out of
    the output using sed or something, but it can be done. The most common
    use of modification times is to find out whether one file is newer or
    older than another, and you do that with '[ file1 -nt file2 ]' and '[
    file1 -ot file2 ]' respectively. If it's something else, give us a bit
    more detail about what you're trying to do.

    Cheers,

    --
    Colin Watson [cjwatson@flatline.org.uk]


    --
    To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
    with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
    Colin Watson Guest

  5. #4

    Default Re: stat question



    Elie De Brauwer wrote:
    >a) do you have the coreutils package installed (which provides the stat binary
    >on my machine
    >
    >b) that is not true, there are manpages for a whole lot of file, for example
    >if you have the mesa development files installed you have the manpages for
    >all Opengl functions available.
    >On my system i have two separate stat manpage i have
    >man 1 stat
    >(this describes the command like i pasted below)
    >man 2 stat
    >(which describes the stat system calls which you can use in c/c++ (and
    >probably other) programs to get information about files on you system.)
    >
    >helios@kafka:~$ dpkg -S /usr/share/man/man2/stat.2.gz
    >manpages-dev: /usr/share/man/man2/stat.2.gz
    >elios@kafka:~$ dpkg -S /usr/share/man/man1/stat.1.gz
    >coreutils: /usr/share/man/man1/stat.1.gz
    >
    >As you can see both manpages (which have the same name but cover different
    >topics) are originating from different packages, so normally installing
    >coreutils should provide you with the binary you need.
    >
    >hth
    >
    >
    Thanks for the clarification on man pages ...

    I don't appear to have the coreutils package installed.
    Something tells me I am missing something obvious but !

    debian:/home/web# apt-cache gencaches
    Reading Package Lists... Done
    debian:/home/web#
    debian:/home/web# apt-cache search coreutils
    debian:/home/web#

    and from aptitude a search for coreutils provides zip, running debian woody

    OK what am I missing !
    Dave



    --
    To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
    with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
    David selby Guest

  6. #5

    Default Re: stat question



    David selby wrote:
    >
    >
    > Elie De Brauwer wrote:
    >
    >> a) do you have the coreutils package installed (which provides the
    >> stat binary on my machine
    >>
    >> b) that is not true, there are manpages for a whole lot of file, for
    >> example if you have the mesa development files installed you have the
    >> manpages for all Opengl functions available. On my system i have two
    >> separate stat manpage i have man 1 stat (this describes the command
    >> like i pasted below)
    >> man 2 stat
    >> (which describes the stat system calls which you can use in c/c++
    >> (and probably other) programs to get information about files on you
    >> system.)
    >>
    >> helios@kafka:~$ dpkg -S /usr/share/man/man2/stat.2.gz
    >> manpages-dev: /usr/share/man/man2/stat.2.gz
    >> elios@kafka:~$ dpkg -S /usr/share/man/man1/stat.1.gz
    >> coreutils: /usr/share/man/man1/stat.1.gz
    >>
    >> As you can see both manpages (which have the same name but cover
    >> different topics) are originating from different packages, so
    >> normally installing coreutils should provide you with the binary you
    >> need.
    >>
    >> hth
    >>
    >>
    >
    > Thanks for the clarification on man pages ...
    >
    > I don't appear to have the coreutils package installed.
    > Something tells me I am missing something obvious but !
    >
    > debian:/home/web# apt-cache gencaches
    > Reading Package Lists... Done
    > debian:/home/web#
    > debian:/home/web# apt-cache search coreutils
    > debian:/home/web#
    >
    > and from aptitude a search for coreutils provides zip, running debian
    > woody
    >
    > OK what am I missing !
    > Dave

    All sorted, used file1 -ot file2 instead as suggested by colin, didn't
    know bash could do that !
    many thanks for your help anyhow.

    Dave

    PS still cant find coreutils or stat, though its not a problem now.

    debian:/home/web# dpkg -i coreutils
    dpkg: error processing coreutils (--install):
    cannot access archive: No such file or directory
    Errors were encountered while processing:
    coreutils
    debian:/home/web# dpkg -i stat
    dpkg: error processing stat (--install):
    cannot access archive: No such file or directory
    Errors were encountered while processing:
    stat
    debian:/home/web#







    --
    To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
    with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
    David selby Guest

  7. #6

    Default Re: stat question

    On Sat, Aug 02, 2003 at 11:55:43AM +0100, David selby wrote:
    > PS still cant find coreutils
    You won't be able to find coreutils on woody. It hadn't been created yet
    then!
    > or stat, though its not a problem now.
    >
    > debian:/home/web# dpkg -i coreutils
    > dpkg: error processing coreutils (--install):
    > cannot access archive: No such file or directory
    > Errors were encountered while processing:
    > coreutils
    > debian:/home/web# dpkg -i stat
    > dpkg: error processing stat (--install):
    > cannot access archive: No such file or directory
    > Errors were encountered while processing:
    > stat
    > debian:/home/web#
    'dpkg -i' doesn't work that way; it takes a .deb filename. Use 'apt-get
    install stat' or some other package manager if you just have the package
    name.

    Cheers,

    --
    Colin Watson [cjwatson@flatline.org.uk]


    --
    To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
    with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
    Colin Watson Guest

  8. #7

    Default Re: stat question

    > PS still cant find coreutils or stat, though its not a problem now.
    >
    > debian:/home/web# dpkg -i coreutils
    > dpkg: error processing coreutils (--install):
    > cannot access archive: No such file or directory
    > Errors were encountered while processing:
    > coreutils
    > debian:/home/web# dpkg -i stat
    > dpkg: error processing stat (--install):
    > cannot access archive: No such file or directory
    > Errors were encountered while processing:
    > stat
    > debian:/home/web#
    Could it be that you want to do:
    # apt-get install stat

    As far as I know, dpkg is only used to install packages, which are already
    downloaded (from ``dpkg --help'': ``dpkg -i|--install <.deb file name>'').

    Does it show up on apt-cache[1]?

    Cheers,
    Johannes

    [1]:
    # apt-cache search ^stat
    ....
    stat - wrapper for stat() and statfs calls
    ....
    # apt-cache show stat
    Package: stat
    Priority: optional
    Section: utils
    Installed-Size: 80
    Maintainer: Michael Meskes <meskes@debian.org>
    Architecture: i386
    Version: 3.3-2
    Depends: libc6 (>= 2.2.4-4)
    Filename: pool/main/s/stat/stat_3.3-2_i386.deb
    Size: 11916
    MD5sum: d576a105c03861f57e9c8b82a9b3dfd5
    Description: wrapper for stat() and statfs calls
    Display all information about a file that the stat() call provides and all
    information about a filesystem that statfs() provides.

    #

    --
    "More than machinery we need humanity" -- Charlie Chaplin, The Great
    Dictator


    --
    To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
    with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
    Johannes Zarl Guest

  9. #8

    Default Re: stat question

    >
    > PS still cant find coreutils or stat, though its not a problem now.
    >
    > debian:/home/web# dpkg -i stat
    > dpkg: error processing stat (--install):
    > cannot access archive: No such file or directory
    > Errors were encountered while processing:
    > stat
    > debian:/home/web#

    Err can I crawl into a hole, please ...

    apt-get install stat works just fine !

    Thanks
    Dave

    PS I think I need a break, Im getting over linuxed.



    --
    To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
    with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
    David selby Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139