LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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
  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
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.
 
  


Reply

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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:19 PM.

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
Open Source Consulting | Domain Registration