#!/bin/bash

# Number of jobs
JOBS=3

# Maximal running jobs
MAXJOBS=999

# End of line
END="\r\t\t\t\t\t\t\t\t"

# Define colors
COLOR_NORMAL="\033[0m"
COLOR_GREEN="\033[32m"
COLOR_RED="\033[31m"

# Line subroutine
line()
{
	echo -e "--------------------------------------------------------------------------"
}

# OK message subroutine
message_ok()
{
	echo -ne "$END$COLOR_GREEN[   OK   ]$COLOR_NORMAL\n"
}

# FAILED message subroutine
message_failed()
{
	echo -ne "$END$COLOR_RED[ FAILED ]$COLOR_NORMAL\n"
}

# Main program
clear
for ((i=1 ; i<=$JOBS ; i++))
do
	# Creating same lenght string numbers
	nummax=`echo $MAXJOBS | wc -c`
	numcounter=`echo $i | wc -c`
	numzero=`expr $nummax - $numcounter`
	JOB=""
	for ((j=0 ; j<$numzero ; j++))
	do
		JOB=`echo $JOB"0"`
	done
	JOB=`echo $JOB$i`

	echo -en "Remove $JOB job files: job_$JOB"
	if (rm -rf job_$JOB) then
               message_ok;
        else
               message_failed;
        fi
done
