Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-26-2008, 07:24 AM   #1
Registered: Sep 2006
Location: Nagpur, Maharashtra, India
Distribution: Debian, Ubuntu, Redhat, Fedora, SLES, OpenSUSE, FreeBSD, Mac OS X
Posts: 221

Rep: Reputation: 31
Question Displaying the Partitions & File-System

Hello all,

I intend to write a shell script that will display the partitions & the respective file-systems. So I am planning to write a Shell Script as given below:

fdisk /dev/sda

But My problem is that when I execute the above script, I am required to enter the "p" manually to display the partition table How can I automate that so that I don't need to enter "p" manually.
Old 03-26-2008, 07:31 AM   #2
Simon Bridge
LQ Guru
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
fdisk already does what you want with the -l option (man fdisk):

fdisk -l /dev/sda

If you pipe the output to a file, you can parse it with sed and awk.


filesystem, partitions, scripts, shell, shell script, shell scripting

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
Linux File System or Partitions? Kabul Linux - Software 3 07-30-2006 03:43 PM
Resizing ext3 partitions (/usr) [file system management] xxx_anuj_xxx Red Hat 5 11-29-2005 03:35 AM
9.2 partitions not added into a 10.1 file system choco66 Mandriva 1 12-10-2004 05:09 PM
Sharing internet & file system between Windows98 & Redhat9 cjs_pro Linux - Networking 2 07-15-2004 07:25 AM
Displaying non-linux Partitions LilGryphMaster Linux - Newbie 15 01-31-2004 09:21 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:16 PM.

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