首页 > 解决方案 > 使用shell将数据从文本文件添加到excel

问题描述

我有以下命令的 2 个输出(使用 SHELL)

输出 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

输出 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

我的实际输出应该是excel。就像输出 1 应该进入第 1 列,输出 2 应该进入第 2 列一样。

请建议。

标签: shell

解决方案


将第一个写入文件。同样对第二个文件也这样做。

cmd 在这里 > file1.txt

2ndcmd 在这里 > file2.txt

然后要逐行合并文件,您可以使用粘贴命令。您可以使用不同的分隔符“\t”并写入 csv

粘贴 file1.txt file2.txt > 合并文件.csv

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


推荐阅读