LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Displaying the Partitions & File-System (https://www.linuxquestions.org/questions/programming-9/displaying-the-partitions-and-file-system-630747/)

paragkalra 03-26-2008 07:24 AM

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.

Simon Bridge 03-26-2008 07:31 AM

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.


All times are GMT -5. The time now is 02:37 PM.