Visit Our UNIX and Linux User Community


Auto-detect drive identifier?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Auto-detect drive identifier?
# 1  
Old 11-10-2009
Auto-detect drive identifier?

Is there a way I could autodetect a drive identifier? For example, below I would like to be able to put "disk1s1" into a variable (meaning that every time that the script I am writing runs I would like to be able to figure out the disk number for my BACKUP 1 Partition). I am not an expert, sorry if this is a stupid question, any help appreciated because I am interested in getting better at this.


Code:
Michael-Fredericks-Mac-Pro:~ Mike$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            700.1 GB   disk0s2
   3:       Microsoft Basic Data                         299.7 GB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *1.5 TB     disk1
   1:                  Apple_HFS Backup 1                998.6 GB   disk1s1
   2:                  Apple_HFS Backup 2                501.7 GB   disk1s2



---------- Post updated at 08:50 AM ---------- Previous update was at 08:27 AM ----------

I used the following code to get the info I want, now I need to store that in a variable. Again, clearly I am not familiar with the convention that should be used.

Code:
diskutil list | grep Backup\ 1 | awk '{print $7}'



---------- Post updated at 08:53 AM ---------- Previous update was at 08:50 AM ----------

nvm, got it, really easy
# 2  
Old 11-10-2009
Code:
diskutil list |awk '/Backup 1/ {print $7}'


Previous Thread | Next Thread
Test Your Knowledge in Computers #406
Difficulty: Medium
Cygwin was originally developed by Cygnus Solutions, which was later acquired by Microsoft.
True or False?

8 More Discussions You Might Find Interesting

1. Hardware

Dell XPS M1330 doesn't detect optical drive

I have a Dell XPS M1330 laptop. The OS is Windows 10. I had to replace the motherboard because it was bad. After replacing the motherboard I noticed the optical (DVD/CD) drive is neither detected in BIOS and OS nor making any noise at all. Everything else seems to be working fine. The optical drive... (3 Replies)
Discussion started by: milhan
3 Replies

2. UNIX for Dummies Questions & Answers

Need help to move .csv file from UNIX path to windows shared drive or c:\ drive

Hi Guys, Can any one help me on this. I need help to move .csv/.xls file from unix path to windows shared drive or c:\ drive? Regards, LKR (1 Reply)
Discussion started by: lakshmanraok117
1 Replies

3. Hardware

How to Clone a Drive with 512 byte Sectors to a Drive with 4096 bytes/sector (AF)?

I have a 320 GB drive which dual boots Windows and Debian: Disk /dev/sda: 320.1 GB, 320072933376 bytes 255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal):... (0 Replies)
Discussion started by: phillipsoasis
0 Replies

4. Shell Programming and Scripting

Help with auto-detect new files/folders then zip and move script

Hello, I need a simple script to Auto-detect new files and folders in the directory. And then I need to zip the new files and bzip2 new folders and move them out of that folder where I am detecting changes to the other folder. Remember, I need simple one. If anyone could do it fast, I may... (1 Reply)
Discussion started by: juzt1s
1 Replies

5. Shell Programming and Scripting

is not an identifier

Hi Guys... I am using the following codes in my script: SID_L=`cat /var/opt/oracle/oratab|grep -v "^#"|cut -f1 -d: -s` SID_VAR=$SID_L for SID_RUN in $SID_VAR do ORACLE_HOME=`grep ^$SID_RUN /var/opt/oracle/oratab | \ awk -F: '{print $2}'` ;export ORACLE_HOME export... (2 Replies)
Discussion started by: Phuti
2 Replies

6. Linux

Auto map network drive using SAMBA with batch file

Hi everyone. I have several shares (see smb.conf below). Each setup fairly similarly, and several groups. My end goals are: 1) to have the share automatically map as the P: drive to members of the employees group 2) to have the share automatically map as the t: drive to members of the tech... (0 Replies)
Discussion started by: unassassinable
0 Replies

7. Shell Programming and Scripting

not an identifier

Hi I have already gone through this topic on this forum, but still i am getting same problem. I am using solaris 10. my login shell is /usr/bash i have got a script as below /home/gyan> cat 3.cm #!/usr/bin/ksh export PROG_NAME=rpaa001 if i run this script as below , it works fine... (3 Replies)
Discussion started by: gyanibaba
3 Replies

8. Solaris

SF V210 CDROM drive auto eject!

Hi, When I insert a cd to CDROM drive in SF V210 Solaris 10 it took seconds then eject it auto! How can I solve this issue? Thanks Regards :) (8 Replies)
Discussion started by: HishamN
8 Replies

Featured Tech Videos