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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:25:35+00:00 2026-05-20T05:25:35+00:00

Greetings! I have been tasked to create a report off files we receive from

  • 0

Greetings!

I have been tasked to create a report off files we receive from our hardware suppliers. I need to grep these files for two fields ‘Test_Version’ and ‘Model-Manufacturer’ ; for each field, I need to capture their corresponding values.

When running each statement separately, I get the results I want:

1) for ‘Test_Version’, it was straightforward:

find . -name "*.VER" -exec grep 'Test_Version=' '{}' ';' -print; 

./(FILE_NAME).VER
Test_Version=2.6.3
./(FILE_NAME).VER
Test_Version=2.4.7

2) for ‘Model-Manufacturer’, , it was a bit tricky since what I need is across multiple lines. I solved this issue by using Perl Regex option -P.

find . -name "*.VER" -exec grep -P 'Model-Manufacturer:.\n.' '{}' ';' -print

./(FILE_NAME).VER
--> Model-Manufacturer:
D12-100
./(FILE_NAME).VER
--> Model-Manufacturer:
H21-100

Ideally, I would like to create a simple report that looks like this

(FILE_NAME)
Test_Version=2.6.3
Model-Manufacturer:    D12-100
(FILE_NAME)
Test_Version=2.4.7
Model-Manufacturer:    H21-100

My attempt to combine both greps is not working i.e nothing is found:

find . -name "*.VER" -exec grep -P 'Test_Version=.Model-Manufacturer:.\n.' '{}' ';' -print

How can I grep to search for both fields and produce the output I want?

  • 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-20T05:25:35+00:00Added an answer on May 20, 2026 at 5:25 am

    I created a test file:

    $ cat test1.VER
    Test_Version=2.6.3
    Model-Manufacturer:
    D12-100
    Test_Version=2.4.7
    Model-Manufacturer:
    H21-100
    Test_Version=2.6.3
    Model-Manufacturer:
    D12-100
    Test_Version=2.4.7
    Model-Manufacturer:
    H21-100
    

    I created a copy, to replicate searching through multiple files:

    $ cp test1.VER test2.VER
    

    Finally, I am able to generate the report you’re looking for using the following string of commands:

    $ find . -name "*.VER" -print -exec egrep -A 1 'Test_Version=|Model-Manufacturer:' {} ';' | sed -e '/Model/N; s/\n/ /'
    ./test1.VER
    Test_Version=2.6.3
    Model-Manufacturer: D12-100
    Test_Version=2.4.7
    Model-Manufacturer: H21-100
    Test_Version=2.6.3
    Model-Manufacturer: D12-100
    Test_Version=2.4.7
    Model-Manufacturer: H21-100
    ./test2.VER
    Test_Version=2.6.3
    Model-Manufacturer: D12-100
    Test_Version=2.4.7
    Model-Manufacturer: H21-100
    Test_Version=2.6.3
    Model-Manufacturer: D12-100
    Test_Version=2.4.7
    Model-Manufacturer: H21-100
    

    egrep allows for extended regular expressions, in which I’m using | as the alternation operator.

    The -A flag to (e)grep, makes it provide a line of context after each match. If your input files have unwanted content after the Test_Version lines, you may need to include a grep -v command piped in between find and sed to strip out the unwanted output.

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

Sidebar

Related Questions

Greetings collective, I am new to Cocoa and have been tasked with working on
Greetings, Well I am bewildered. I have been tasked with updating a PHP script
Greetings all, As someone new to ASP.Net, I have been modifying web.config files for
Greetings. I have been looking at Literate Programming a bit now, and I do
Greetings, I have a particular object which can be constructed from a file, as
Greetings. I've been tasked with debugging part of an application that involves a Regex
Greetings! I inherited a C#.NET application I have been extending and improving for a
Greetings all: I currently am building a web application, and have been debating whether
Greetings stackoverflow. I have been tinkering about with a SOAP client using PHP5's native
Greetings: I have put together a RESTful web service in .NET 3.5 that takes

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.