LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
LinkBack Search this Thread
Old 03-26-2008, 07:24 AM   #1
paragkalra
Member
 
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:

#!/bin/bash
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
Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 197Reputation: 197
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.
 
  


Reply

Tags
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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 09:57 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration