Thursday 11 September 2014

Script to detect how many pen drives are attached to your system



#!/bin/bash
clear
echo "`sudo fdisk -l | grep "/dev/*" | grep -i "GB\|MB" | wc -l` no of disk attached to your pc"
echo "`sudo fdisk -l | grep "/dev/*" | grep -i "MB" | wc -l ` of usb is auttached currently named:"
a=`sudo fdisk -l | grep "/dev/*" | grep -i "MB" | wc -l`
if [ $a -eq 1 ]
then
sudo fdisk -l | grep "/dev/*" | tail -1 | cut -c-10
elif [ $a -eq 2 ]
then
sudo fdisk -l | grep "/dev/*" | tail -2 | cut -c-10
elif [ $a -eq 3 ]
then
sudo fdisk -l | grep "/dev/*" | tail -3 | cut -c-10
else
echo no usb attached.
fi

No comments:

Post a Comment

Popular Posts