I'm trying to isolate attached hard drives that auto-mount to /media so that I can use them as variables in a bash script...
so far I'm here:
variable=$(ls /media | grep -v cdrom )
This lists all the connected drives, each on it's own line and doesn't list anything I don't want (cdrom folders)... is there a way using grep or awk to take the output of my "grep -v cdrom" and print a specific line...
I'll only ever have 6 drives connected at time, so I figure I'd just use the code 6 times to get each drive and keep it simple... Obviously the below script doesn't work but, something like this...
drive1=$(ls /media | grep -v cdrom | awk line1 )
drive2=$(ls /media | grep -v cdrom | awk line2 )
drive3=$(ls /media | grep -v cdrom | awk line3 )
drive4=$(ls /media | grep -v cdrom | awk line4 )
drive5=$(ls /media | grep -v cdrom | awk line5 )
drive6=$(ls /media | grep -v cdrom | awk line6 )
I did quite a bit of searching for this, but I must not using the correct terminology, because I couldn't find anything?
Thanks for any help!
-Starcast