Skip to content

Instantly share code, notes, and snippets.

@SippieCup
Last active August 4, 2021 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SippieCup/4c15ec25e6427cd583ef8cc8b77b5907 to your computer and use it in GitHub Desktop.
Save SippieCup/4c15ec25e6427cd583ef8cc8b77b5907 to your computer and use it in GitHub Desktop.
Find and fills all available free space in root dir.
#!/bin/bash
ROOT=$1
PORT=$2
DELETE=$3
free_space () {
FREE_SPACE=$(df $1 | awk '{print $4}' | tail -n 1)
#echo $FREE_SPACE
echo $(($FREE_SPACE/1048576))
}
for DIR in $ROOT/*/; do
cd $DIR
while [ "$(free_space $DIR)" -gt 104 ]
do
echo "Listening in $DIR - $(free_space $DIR)G Free"
nc -p $PORT -l | tar -x
echo "Plot saved in $DIR"
if [[ "$DELETE" == "true" ]]; then
ls plot-k32-2021-0[0-6]*.plot | head -n 1 | xargs rm --
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment