I have some old file in my Linux server and I need to remove those files which are older than 5 days based on the threshold value.log_space_checker() {        Use=$(df -kh /logs | awk 'END{gsub(%,); print $4}');        DATAUSE=$(df -kh /logs | awk 'END{gsub(%,); print $4}');}remove_files(){        RemoveFiles=/logs/abc/abc.log.*        find $RemoveFiles -mtime +1 -type f -delete        }disk_space_monitor() {        log_space_checker;        if [[ $DATAUSE -gt $TH ]] ; then                remove_files;        fi}TH=7disk_space_monitorcan any one help me whether the script is correct.
Script to remove files based on threshold value
linux;shell script
Me, I'd go for something like this#!/bin/bash##########################################################################log_space_checker() {    local target=$1                 # Log file template    local directory=${target%/*}    # Directory holding log files    df -k $directory | awk 'NR>1 {print gensub(^.* ([1-9][0-9]*)%.*, \\1, 1)}'}#########################################################################remove_files(){    local logfiles=$1               # Log file template    find $logfiles -mtime +1 -type f -print ## -delete}#########################################################################disk_space_monitor() {    local threshold=$1              # Threshold%    local target=$2                 # Log files to delete     local pct_used=$(log_space_checker $2);    if [[ $pct_used -gt $threshold ]]    then        remove_files $2    fi}######################################################################### Go#threshold=7                           # % usage above which we will deletelogfiles='/logs/abc/abc.log.*'        # ...log files matching this patterndisk_space_monitor $threshold $logfiles