Command line sensor - Count files

Hi, I use Home Assistant on docker on Ubuntu 20 with motioneye for record clip video in a folder.
I mapped this folder with a mount in home assistant and I create a command line sensor for count video file in this folder. This work.
The best would be to count only the files of the current day, but the sensor not work.
This is in my sensor.yaml

  - platform: command_line
    name: rec_terrazzo
    command: "ls -l /share/nvr/Terrazzo/*.mp4 | wc -l"

  - platform: command_line
    name: rec_terrazzo_today
    command: "ls -l --time-style=+%D /share/nvr/Terrazzo/*.mp4 | grep $(date +%D) | wc -l"

The code if entered in the terminal gives the correct result

sudo ls -l /usr/share/hassio/share/nvr/Terrazzo/*.mp4 | wc -l
sudo ls -l --time-style=+%D /usr/share/hassio/share/nvr/Terrazzo/*.mp4 | grep $(date +%D) | wc -l

but the sensor in home assistant not work

any help?

You have to test your command inside the container

$ docker exec -it ha-test /bin/bash

bash-5.1# ls -l --time-style=+%D . | grep $(date +%D) | wc -l
ls: unrecognized option: time-style=+%D
BusyBox v1.33.1 () multi-call binary.

Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...

List directory contents

        -1      One column output
        -a      Include entries which start with .
        -A      Like -a, but exclude . and ..
        -x      List by lines
        -d      List directory entries instead of contents
        -L      Follow symlinks
        -H      Follow symlinks on command line
        -R      Recurse
        -p      Append / to dir entries
        -F      Append indicator (one of */=@|) to entries
        -l      Long listing format
        -i      List inode numbers
        -n      List numeric UIDs and GIDs instead of names
        -s      List allocated blocks
        -lc     List ctime
        -lu     List atime
        --full-time     List full date and time
        -h      Human readable sizes (1K 243M 2G)
        -S      Sort by size
        -X      Sort by extension
        -v      Sort by version
        -t      Sort by mtime
        -tc     Sort by ctime
        -tu     Sort by atime
        -r      Reverse sort order
        -w N    Format N columns wide
        --color[={always,never,auto}]   Control coloring
1 Like

maybe the --full-time parameter might be the right one.
But do you know how it should be set up? the date should be that of the current day

$ ls -l --full-time | grep  $(date +%Y-%m-%d) | wc -l

It’s work!!!
Thank so much