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 6320999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:04:24+00:00 2026-05-24T16:04:24+00:00

Hey guys I’ve got a text file that a script creates (specifically dmidecode >

  • 0

Hey guys I’ve got a text file that a script creates (specifically dmidecode > dmidecode.txt) and I want to be able to grab the contents of “Product Name:” so in this case “HP t5740e Thin Client” but it will be slightly different for other machine types. I could just use sed to count to line 44 and then slice it up until I get what I want but I’d like for it to be more dynamic than that.

Text file:

41  Handle 0x0001, DMI type 1, 27 bytes
42  System Information
43      Manufacturer: Hewlett-Packard
44      Product Name: HP t5740e Thin Client
45      Version:   
46      Serial Number: CNW1160BZ7
47      UUID: A0B86400-6BBD-11E0-8325-92EEE331A344
48      Wake-up Type: Power Switch
49      SKU Number: XL424AA#ABA
50      Family: 103C_53302C

Code I have that doesn’t seem to work:

sed -c -i "s/\($TARGET_KEY *Product Name :*\).*/\1$REPLACEMENT_VALUE/" dmidecode.txt

I get the feeling my regular expressions is way off (probably because the initial examples I looked at tainted my “vision”)

Any help is greatly appreciated!
Also, anyone know of any good regular expression references I can check out?

UPDATE:
Ok I was able to spend a little more time on this, found some better examples and got this out of my research:

grep -e "Product Name: HP" -e "Product Name: hp" dmidecode.txt | awk '{print}'

When I add '{print $NF}' it prints just the last word, is there a way to modify print to include everything after the search string instead of the whole line itself?

Also, I should have noted this from the beginning, but I need the output to go into a variable.

  • 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-05-24T16:04:24+00:00Added an answer on May 24, 2026 at 4:04 pm

    With sed:

    sed -n -e '/Product Name/{s/.*://p}'
    

    If you want to remove spaces after ::

    sed -n -e '/Product Name/{s/.*: *//p}'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys. I have a method that gets called each second which I want
hey guys, I have mypage.com/user-login.php?action=register and I want to be able to call mypage.com/register
Hey guys I want to make a file uploader on my website but i
Hey guys i wrote a quick test. I want delete to call deleteMe which
Hey guys i want to execute my SQL statement but im having synatx trouble,
Hey guys, I want to store a categorized list of URLs. This is an
Hey guys, I've got a neat dropdown menu and also a flashfile in my
Hey guys, I'm writing a word wrap function to format console text in C++.
Hey guys I have a query that selects data and organizes but not in
Hey guys, I have a CS exam tomorrow. Just want to get a few

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.