Skip to content

Instantly share code, notes, and snippets.

@progress44
Created August 8, 2019 13:02
Show Gist options
  • Select an option

  • Save progress44/f37b0716a6676d5978001ac734bc3706 to your computer and use it in GitHub Desktop.

Select an option

Save progress44/f37b0716a6676d5978001ac734bc3706 to your computer and use it in GitHub Desktop.

Revisions

  1. progress44 created this gist Aug 8, 2019.
    18 changes: 18 additions & 0 deletions loop.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash
    DIR=/var/lib/docker/containers
    FILES=$(ls $DIR)
    for f in $FILES
    do
    echo "Processing $f dir..."
    # take action on each file. $f store current file name
    ls -lash $DIR/$f | grep .log

    LOGS=$(ls $DIR/$f/ | grep .log)

    for l in $LOGS
    do
    echo "emptying $l logfille"
    echo "" > $DIR/$f/$l
    done

    done