#!/bin/bash


#  x=axc:fddb:cads
#x='UUID="17dbbb00-297c-4f8a-87da-2cb1ada4aa96"' 
# echo ${x%=*}
#  a:b
# echo ${x#*=}
#  b:c

function output_result
{
uuid=$1
label=$2
type=$3
device=$4
echo \# device=$device
echo UUID=$uuid  /media/$label   $type defaults   0 0

}

   


sudo blkid | grep LABEL="*" | while read line ; do
#    echo one line is:$line
    for f in $line; do
#	echo $f
	if [[ $f = /dev/* ]]; then
	    device=$f
	else
	    if [[ $f =  UUID=* ]]; then
		
		uuid=${f#*\"}
		uuid=${uuid%\"}
#		echo uuid=$uuid
	    else
		if [[ $f = LABEL=* ]]; then
		    
		    label=${f#*\"}
		    label=${label%\"}
#		    echo label=$label
		else
		    if  [[ $f = TYPE=* ]]; then
			type=${f#*\"}
			type=${type%\"}
#			echo type=$type
		    fi
		fi
	    fi
	fi
    done
    output_result $uuid $label $type $device
done
	
