1

I have 2 outputs from below commands (Using SHELL)

Output 1

bash-4.2$ cat job4.txt | cut -f2 -d ":" | cut -f1 -d "-"
Gathering Facts
 Upload the zipped binaries to repository
 Find the file applicatons in remote node
 Upload to repository
 include_tasks
 Check and create on  path if release directory exists
 change dir 
 include_tasks
 New release is unzipped 
 Starting release to unzip package delivered 
 Get the file contents
 Completed
Playbook run took 0 days, 0 hours, 5 minutes, 51 seconds

Output 2

bash-4.2$ awk '{print $NF}' job4.txt
4.78s
2.48s
1.87s
0.92s
0.71s
0.66s
0.55s
0.44s
0.24s
0.24s
0.24s
0.03s
seconds

My actual output should be in excel. Like Output 1 should go to column 1 and Output 2 should go to column 2.

Kindly suggest.

4
  • 1
    printf "%s %s\n" $(cut -f2 -d ":" job4.txt | cut -f1 -d "-") Commented Jan 1, 2020 at 6:35
  • Last line of Output1 has commas. Can the commas be part of any line? Commented Jan 1, 2020 at 7:53
  • yes last line can be ignored, rest of the outputs will be printed in two columns Commented Jan 1, 2020 at 8:02
  • provide some sample inputs lines (at least 3) from job4.txt . And the corresponding output lines. The answer script is simple awk. Commented Jan 1, 2020 at 9:55

2 Answers 2

1

Assuming your output1 and output2 are in files file1.txt and file2.txt and last line of output1 can be ignored:

paste -d"," file1.txt file2.txt > mergedfile.csv
Sign up to request clarification or add additional context in comments.

Comments

1

write the first out to a file . Similarly do it for 2nd one file as well.

cmd goes here > file1.txt

2ndcmd goes here > file2.txt

Then To merge files line by line, you can use the paste command. And you can use a delimiter "\t" as different and write to csv

paste file1.txt file2.txt > mergedfile.csv

Ref: https://geek-university.com/linux/merge-files-line-by-line/

4 Comments

I had used below command ``` paste -d "\t" file1.txt file2.txt > output.csv ```
But file1 and file2 is merged in a single cell. Not in different columns
Output1 and output2 are mergered but in csv it is displayed in a single cell. Need output 1 in column 1 and output2 in column 2
While opening the csv, you need to mention the delimiter as tab . So you will be able to see it in two columns Ref: atensoftware.com/p90.php?q=187

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.