Re: Find and sort by date

From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 11/25/03

  • Next message: phn_at_icke-reklam.ipsec.nu: "Re: How can I measure the network load ?"
    Date: Tue, 25 Nov 2003 15:35:20 +0100
    
    

    2003-11-25, 05:45(-08), Chistian:
    > I`m writing a php script using a standard unix command on my RH 8 box.
    > What I want to do is to search trought my music directories and
    > display the 5-10 last modified files.

    zsh -c 'print -rl -- /usr/ftp/music/Mp3/**/*(D.om[5,10])'

    Or, as you've got a GNU system:

    find /usr/ftp/music/Mp3 -type f -printf '%Ts %p\0' \
      | tr '\0\n' '\n\0' | sort -rn | head -n 10 \
      | tail -n +5 | cut -d' ' -f2- | tr '\0' '\n'

    And if you want to postprocess that list:

    find /usr/ftp/music/Mp3 -type f -printf '%Ts %p\0' \
      | tr '\0\n' '\n\0' | sort -rn | head -n 10 \
      | tail -n +5 | cut -d' ' -f2- | tr '\0\n' '\n\0' \
      | xargs -r0 sh -c 'shift "$1"

      for file; do
        # whatever with "$file"
      done

      ' 2 1

    With zsh:

    for file (/usr/ftp/music/Mp3/**/*(D.om[5,10])) {
      # whatever with $file
    }

    -- 
    Stéphane                      ["Stephane.Chazelas" at "free.fr"]
    

  • Next message: phn_at_icke-reklam.ipsec.nu: "Re: How can I measure the network load ?"

    Relevant Pages

    • Re: Newbe php help
      ... > I have an HTML form with Firstname, lastname, address ... The form should call a php script in it's 'action' attribute, ... in append mode, writing to the file, and closing the file. ... server conf file - usually named '.htaccess' if the server is Apache). ...
      (comp.lang.php)
    • Re: File permissions for a wiki-like site
      ... I'm writing a site where a handful of people will be able to edit ... content to be writable by my PHP script. ... The only one doing the writing will be the Apache user itself. ...
      (comp.lang.php)
    • checkbox problem
      ... I am writing a php script to simulate dice rolls for a rpg campagne. ...
      (alt.php)
    • Re: PHP to echo a line in html source...
      ... > Say i am writing a few lines of code in php script as so... ... > On my html source the code looks like this... ...
      (comp.lang.php)
    • Re: parsing
      ... "Fire Juggler" wrote in message ... > Hi, in a php script i'm writing, i want to set ...
      (comp.lang.php)