Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7949615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:02:49+00:00 2026-06-04T02:02:49+00:00

I am trying to get disk information from fdisk -l output on linux. fdisk

  • 0

I am trying to get disk information from fdisk -l output on linux.

fdisk -l | grep -E 'Disk /dev/sd.\:'

I get the following output.

Disk /dev/sde doesn't contain a valid partition table
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes

but what I want to get is

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes

I tried to do this

fdisk -l | grep -E 'Disk /dev/sd.\:' | grep -v "contain" 

but I have no idea why grep is not ignoring the line containing “contain”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:02:50+00:00Added an answer on June 4, 2026 at 2:02 am

    Try this command:

    fdisk -l 2>/dev/null | grep -E 'Disk /dev/sd.\:'
    

    OR simply:

    fdisk -l 2>/dev/null
    

    Problem is that the line Disk /dev/sde doesn't contain a valid partition table is being generated as error and being written on stderr instead of stdout.

    Pipe in unix only pipes output written on stdout from previous command with the command on RHS of pipe hence your grep command is only working on 2nd and 3rd line while 1st line on your terminal is coming from stderr.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get information like OS version, hard disk space, disk space available,
I am parsing text output from a disk array that lists information about LUN
I am trying to get some files from a mounted read-only disk on a
I'm trying to get the size on disk of a file in iOS using
In an attempt to develop a hard disk analytic tool, I'm trying to get
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
Trying to get a JSON output to work with jqGrid 'userdata' option. The example
I'm currently trying to get disk space in byte en used space in byte
I'm trying to get a C++ service to load an XML document from a
I'm trying to make a webservice (WCF) to get information about my server. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.