in Linux, suppose mount command return this
在Linux中,假设mount命令返回此项
/dev/sdc1 on /media/ELF (^-^)V type vfat
/dev/sdb1 on /media/PENDRIVE type vfat
all I want to do is get all mount point of my usb disk.
我想做的就是获取usb磁盘的所有挂载点。
I did that already, using combination of grep and sed I can get these:
我已经这样做了,使用grep和sed的组合我可以得到这些:
/media/ELF (^-^)V
/media/PENDRIVE
the problem is, when I do for loop in bash, those text will become 3 part instead of 2 parts , I mean :
问题是,当我在bash中进行循环时,那些文本将变为3部分而不是2部分,我的意思是:
suppose I put the result of those text in LIST
假设我将这些文本的结果放在LIST中
for list in $LIST; do
echo $list
done;
the result of that for loop becomes
for循环的结果变成了
/media/ELF
(^-^)V
/media/PENDRIVE
how to handle this issue? or are there any easier ways to get mount point of my usb disk?
如何处理这个问题?或者有没有更简单的方法来获取我的USB磁盘的挂载点?
Thanks
谢谢
1 个解决方案
#1
1
If you've already extracted the mountpoint paths and the only issue is to process them in a loop:
如果您已经提取了挂载点路径,唯一的问题是在循环中处理它们:
while read -r mountpoint; do
echo "[$mountpoint]"
done < <(mount | grep /media | grep uhelper=udisks | sed -e 's/\/dev\/.*on //g' -e 's/ type .*//g')
#1
1
If you've already extracted the mountpoint paths and the only issue is to process them in a loop:
如果您已经提取了挂载点路径,唯一的问题是在循环中处理它们:
while read -r mountpoint; do
echo "[$mountpoint]"
done < <(mount | grep /media | grep uhelper=udisks | sed -e 's/\/dev\/.*on //g' -e 's/ type .*//g')