Saturday, June 29, 2019

Bash - Another thing for the lazy: umount by name

Hi, just another script. You won't believe how many errors you can get before this simple thing works. Sometimes I wonder if my brain does it just for kicks, to see what funny message we can get this time. Or maybe it is too lazy to bother with heuristics and just goes over all the imaginable options. Surprisingly, the second thing feels like an easier one.

Or maybe it does both: 

#!/bin/bash

if [ -z $1 ]
  then printf "\nPlease provide drive name (label)\n\n"
    exit
fi

drivelabel = $1

cat /etc/mtab | grep ${drivelabel} | cut -d " " -f1 | xargs umount

No comments:

Post a Comment