#!/bin/sh
#CCCP script by hampa@chello.se
#delete dctc queue scripte
#shows the queye list and let you choose what to delete
exec 6<&0
count=0

cccp -q > /tmp/cccp_tmp.txt 2>/dev/null
exec < /tmp/cccp_tmp.txt
while read line
do
	let "count += 1"
	#echo $count $line
	#echo $line 
	all[$count]=$line
	echo $count - ${all[$count]}
done

if [ "$count" = "0" ]
then 
	echo No transfer found
	exit 0
fi

exec 0<&6 6<&-
#cat 1.txt | awk '{printf("%i %s\n", FNR, $0)}'
echo "enter line number to remove or q to quit: "
while read item
do
#echo $item
	if [ "$item" = "q" ]
	then
		exit 0
	fi
	echo ${all[$item]} |  cut -c10- | cut -d\| -f 1 | xargs -n1 -exec cccp -O -k
	echo "enter line number to remove or q to quit: "
	#echo ${all[$item]} | cccp -q | cut -c10-18 | xargs -n1 -exec cccp -k
done
