#!/bin/bash
input=$1
tmp='tmp.txt'
if [[ -n "$input" ]]; then
touch $tmp
while read -r line; do
lineB=$(($line-1))
lineBefore=''
job=`cat $input | sed -n "${line}p" | sed s/|//g`
command=`echo "$job" | cut -d " " -f 6- | sed s/|//g`
if [ $lineB -gt 0 ]; then
lineBefore=`cat $input | sed -n "${lineB}p" | sed s/#//g`
fi
if [ -n "$lineBefore" ] ; then
output=`echo "$job" | sed "s|$command|$lineBefore|g"`
echo "$output" >> $tmp
else
echo "$job" >> $tmp
fi
done < <(cat $input | egrep -vn ^# | awk '{print $1}' | cut -d ":" -f 1); cat $tmp | cronv -d 1d --from-time=0:00 -t Crontab
rm $tmp
else
echo "Podaj plik źródłowy"
fi