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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:40:52+00:00 2026-06-12T17:40:52+00:00

I’m really new at using awk/sed So, I have text file that is called

  • 0

I’m really new at using awk/sed

So, I have text file that is called performance.log that has following info

CPU 1 2 3 4 5 6
RAM 2 3 4 5 6 7
HAR 3 4 5 6 7 8

And with in the code in performance-eval.sh, function generates following info

Cur_CPU=10
Cur_RAM=11
Cur_HAR=13

I want to insert and save Cur_CPU,RAM,HAR to performance.log.
Cur_CPU will go to first row, second column
Cur_RAM will go to second row, second column
Cur_HAR will go to third row, second column

So that resulting performance.log would be

CPU 10 1 2 3 4 5 6
RAM 11 2 3 4 5 6 7
HAR 13 3 4 5 6 7 8

I’m not sure how to add 3 different values into 3 different columns.
Thanks for your help!

  • 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-12T17:40:53+00:00Added an answer on June 12, 2026 at 5:40 pm

    The easiest solution would be to use the join command, but first you need to process the output of function that generates the additional info:

    function | sed -e 's/^Cur_//;s/=/ /' | sort > myfile2.txt
    join myfile2.txt myfile1.txt -1 1 -2 1
    

    We start by removing the Cur_ from the start of each line, then we replace = with a space character. Also, join expects both inputs to be properly sorted.

    The -1 1 argument tells join that for the first file, it should use the first field as a join field. Analogously, -2 1 tells join that for the second file, it should use the first field too (in some implementations you could shorten into a single -N 1, so it uses the first field for both files).

    The join field is used as so: when join finds a line in the first file with the same join field as the line on the second file, the output contains the merged lines. Notice that the order of the files in the command line is important to the order of the fields in the final output.

    Hope this helps =)

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a reasonable size flat file database of text documents mostly saved in
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.