MyKroFt Posted December 10, 2021 Share Posted December 10, 2021 ok, i am not a bash script person at all, this should be simple but i am at a loss I have a expander attached, so some of my drive devices are 4 characters long, 5 with partition number added need to know how to modify the following code: load_drives() { ls -l /dev/disk/by-id/ | egrep 'ata\-' > ${TMPFILE} # rwxrwxrwx 1 root root 9 Apr 20 08:04 ata-Hitachi_HTS722020K9SA00_071007DP0400DTG101HA -> ../../sdf # lrwxrwxrwx 1 root root 10 Apr 20 08:04 ata-Hitachi_HTS722020K9SA00_071007DP0400DTG101HA-part1 -> ../../sdf1 # I know it's inefficient. # but piping mount into loop creates a subprocess # whereby the export inside the loop never gets # back to the parent. i=0 while read PERMS LINKS OWNER GROUP XX MONTH DD HHMM MODEL LINKER DEV do # ${parameter:offset:length} NAME=${DEV:6:4} # Save Whole Drive DEV=${DEV:6:3} # Remove Partition # if [ ${DEV} != ${NAME} ]; then continue; fi for OMODEL in ${OMIT_MODELS[*]} do length=${#OMODEL} if [ ${MODEL:0:$length} = ${OMODEL} ];then OMIT=1;fi done if [ ${OMIT:=0} -gt 0 ] then OMIT=0 continue fi DRIVES[$i]="/dev/${DEV}" MODELS[$i]="${MODEL}" CHOICE[$i]="/dev/${DEV} ${MODEL}" ((i++)) done < ${TMPFILE} rm -f ${TMPFILE} } in the NAME and DEV i changed the length to 5 and 4, but that still gives me listing with the partition number any assistance? thanks Myk tmpfile Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.