How to handle spaces in script
- From: James Egan <jegan473@xxxxxxxxxxx>
- Date: Sun, 17 Oct 2010 16:21:06 GMT
I have the unmount() function below in my ~/.bashrc. It allows me
to unmount most file systems just by typing unmount. I now have a
USB drive mounted with a space in the file name like
/dev/sdf1 233G 152G 82G 66% /media/Passport WD-1
I've tried numerous ways to handle the space in the path name
"/media/Passport WD-1". How can this space or spaces be handled?
# Get sdXX or srXX drives, or CIFS mounted file systems. The -f3,4 will
# handle a path name with ONE space in it.
mntpoints="$(mount | egrep '192.168|\/dev\/sd|\/dev\/sr|cifs|loop' | cut -d ' ' -f3,4 | grep -v type)"
if [ "$mntpoints" ]; then
for i in $(echo "$mntpoints"); do
if [ "$i" != '/' ]; then
# if [ "$i" ]; then
echo Unmounting "$i"
sudo /bin/umount "$i"
echo "No mounted file systems found."
- Prev by Date: cheap *** lv, gucci, chanel, coach handbags (www.nike-black.com)
- Next by Date: Re: How to handle spaces in script
- Previous by thread: cheap *** lv, gucci, chanel, coach handbags (www.nike-black.com)
- Next by thread: Re: How to handle spaces in script