One desired feature of the program was that it would have the options to either assume the target hard drive would be in a certain place and attempt the changes or to find all accessible drives and mount them and make changes to all of them. Once again, searching the internet and asking for help provided the commands I needed. It turns out that using 'awk' to choose out a pattern something like /dev/sd[a-z][0-9]/ and then { print $6 } was the way to select only the 6th column of any line containing the pattern.
Integrating this into a while loop was also something that I needed help with since I didn't know about <( functionality in bash scripts. So what I had at the end was something like
while read mPoint do #stuff done < <(df -P | awk '/Sda[a-z][0-9]/ { print $6 })Which would take the output of all the commands in parenthesis (find all mounted partitions, then choose out the patterns and print only column 6) and load the "answer" into the variablemPoint. Then I could do things with $mPoint inside the while loop. This technique would be used again later to mount all drives, but I may still change that.
No comments:
Post a Comment