Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is there any way to find out if a given device exists?
I have a small script that asks user to type in name of a device and I want to check if the device exists in /dev dir.
So far I have:
The only problem is that the while statement checks for DIRECTORIES instead of devices. So if that code should work for any folder that exists in /dev. However, hda, hdb, sda are devices and therefore don't count as dir and thus don't pass that statement.
Please Help. I am very new to linux and I already did some research before turning to experts here.
The find command looks like it might do just what you want. At a terminal shell prompt, type "info find" (without the "s) to pull up loads of local documentation on how find works. My understanding is that find can also work with -b and -c as listed above, as for example "find /dev -type b -name 'hd*'"
if the task is to check for the existance of a known file name, why search a directory for it? ust see if it's there or not in the least intensive and most functional way, i.e. with a test.
No, I need to know the name of the primary HDD and I want to ask the user until I am provided with a proper device name. That's why the loop is there. The task is to create a new partition on that HDD using FDISK and then backup the first partition using PARTIMAGE.
Last edited by branche_dude; 07-20-2006 at 09:25 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.