I am trying to crate a folder with the label and uuid of a media device plugged in as its name, on another flash drive which I am using to log. I have the following code:
LOGDEVICELABEL=FLASHDRIVENAME MD=`lsblk -I 8 -o label,uuid -n|sed -e '/^$/ d' -e '/^$LOGDEVICELABEL.*$/ d'` MDLOGDIR=/media/$LOGDEVICELABEL/Log/$MD mkdir $MDLOGDIR
The problem is that the value pf the variable
$MD has a space in the beginning which I cannot get rid of. That space causes mkdir to treat
$MDas two separate arguements.
MDLOGDIR=`sed 's/ // g' <<</media/$LOGDEVICELABEL/Log/$MD`
Which only removes the space between the UUID and the Label (which is also necessary) but does not remove the space between