代码: 全选
#!/bin/bash
#used to mount a iso image file to /media
echo please input your iso file path and name
echo And between the path and name ,type a "' '""<space>"
if [ "$1"x = ""x ]|| [ "$2"x = ""x ]
then
echo '$1' = $1
echo '$2' = $2
echo check out '$1' and '$2'
exit 1
fi
if [ -f $1$2 ]
then
echo iso image file do exists..
else
echo "iso image file '$1$2' don't exists.."
exit 1
fi
filename=$2
echo $filename
echo make a file to mount the iso image
echo ${filename%%.iso}
sudo mkdir -p /mnt/${filename%%.iso}
sudo mount -o loop $1$2 /mnt/${filename%%.iso}
exit 0
schspa@schspa-Laptop:~/桌面/programming/shell$ ./mount_iso.sh /media/schspa/exp/systemimage/ ubuntu-13.04-desktop-amd64.iso
please input your iso file path and name
And between the path and name ,type a ' '<space>
iso image file do exists..
ubuntu-13.04-desktop-amd64.iso
make a file to mount the iso image
ubuntu-13.04-desktop-amd64
/bin/rm: 无法删除"/run/user/root/gvfs": 是一个目录
mount: warning: /mnt/ubuntu-13.04-desktop-amd64 seems to be mounted read-only.
/bin/rm: 无法删除"/run/user/root/gvfs": 是一个目录
不知道问什么会有这个输出,求大神。是脚本的问题吗??
/bin/rm: 无法删除"/run/user/root/gvfs": 是一个目录
另外mount_iso.sh /media/schspa/exp/systemimage/ubuntu-13.04-desktop-amd64.iso
这种字符串怎么吧后边的ubuntu-13.04-desktop-amd64.iso和路径/media/schspa/exp/systemimage提取出来??