LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-25-2016, 05:04 PM   #16
iFunction
Member
 
Registered: Nov 2015
Posts: 206

Original Poster
Rep: Reputation: Disabled

Hi there,

Thanks very much for the input, I am aware of these concepts as I have some experience with C, python and visual basic and in those, I don't have so much trouble. For some reason, Bash syntax is a little hard to grasp as there is so much of it.

I shall look into these tomorrow, as this is the point where some of my other scripts got a little bit stuck, so it is a barrier I need to push through.

Kind regards

iFunc
 
Old 02-26-2016, 08:46 AM   #17
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
That is what /dev/disk/by-label or /dev/disk/by-id are used for.

If you happen to look in /dev/disk/by-id (use ls -l /dev/disk/by-id) you will be able to confirm the hardware identity of the device. In my case, I have a kingston memory stick:

Code:
$ ls -l /dev/disk/by-id/usb*
lrwxrwxrwx. 1 root root  9 Feb 26 08:38 /dev/disk/by-id/usb-Kingston_DataTraveler_3.0_60A44C3FAC2DBFA0298A016C-0:0 -> ../../sdj
lrwxrwxrwx. 1 root root 10 Feb 26 08:38 /dev/disk/by-id/usb-Kingston_DataTraveler_3.0_60A44C3FAC2DBFA0298A016C-0:0-part1 -> ../../sdj1
I now know it has been assigned /dev/sdj, and the partition /dev/sdj1.

You can then put "/dev/disk/by-id/usb-Kingston_DataTraveler_3.0_60A44C3FAC2DBFA0298A016C-0:0-part1" in a script and know that ONLY that device will be used. It won't matter what /dev/disk/sdxxxx gets assigned as the
id is taken from the physical device.
 
Old 02-26-2016, 09:02 AM   #18
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,463
Blog Entries: 10

Rep: Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639Reputation: 1639
Quote:
Originally Posted by iFunction View Post
Hi there,

Thanks very much for the input, I am aware of these concepts as I have some experience with C, python and visual basic and in those, I don't have so much trouble. For some reason, Bash syntax is a little hard to grasp as there is so much of it.

I shall look into these tomorrow, as this is the point where some of my other scripts got a little bit stuck, so it is a barrier I need to push through.

Kind regards

iFunc
I always say:
Quote:
If you can type it on a command line, you can script it in BASH
So if there are commands you can type to get output and then visually see that you have a drive somewhere, etc, then you can write a script to perform similar commands and search for strings or regular expressions to attain your result. That would be brute force, and you'll not be 100% your first attempts, but it will likely bring you closer to your desired result. A good thing to do is try the brute force method, find something which works, post it, and then see if others have suggestions for improvement.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script-how can user choose how long to run it for? rmcateer Programming 3 02-23-2015 10:10 PM
udev rule to rename /dev/sdx as /dev/sdr does not work :-( on OS 11.2 tkmbe SUSE / openSUSE 2 05-10-2012 02:53 AM
Associating /dev/sdX with a drive. stympman Linux - Hardware 6 12-18-2011 02:18 AM
Force /dev/sdX? to remain? tbeehler Linux - Software 2 05-08-2008 05:29 PM
/dev/sdx question Fill Linux - Newbie 3 10-05-2007 07:31 AM


All times are GMT -5. The time now is 11:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration