使用 awk 抓取随机行并附加到新列?
所以我有一个文档“1”,它是一列。我有 3 个文件,每个文件有一列,我想将从每一列中随机选择的行附加到文档 1 的行上。
就像
awk 'NR==10' moves.txt 'NR==1' propp_tasks.txt
打印出来
10.Qg3 Bb4+
First function of the donor
我想要的那样
10 Qg3 Bb4+ First function of the donor
: Is there a good way to do this with awk?我一直在尝试使用 for 循环设置一个 bash 脚本,但我不知道如何循环索引,因此文档 1 的第 n 行、第 2,3 和 4 列将附加到那里。我觉得这应该非常非常简单......
So I have a document "1", which is one column. I have 3 files with one column each and I want to append a randomly selected line from each of those columns onto the document 1's line.
So like
awk 'NR==10' moves.txt 'NR==1' propp_tasks.txt
prints out
10.Qg3 Bb4+
First function of the donor
when I want it to be:
10 Qg3 Bb4+ First function of the donor
Is there a good way to do this with awk? I had been trying to set up a bash script with a for loop but I didn't know how to cycle the indices so on line n of document 1, columns 2,3 and 4 would be appended on there. I feel like this should be really, really simple...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果第一个文件的长度和其他 3 个文件的组合长度不同,则需要做更多的工作。
If the length of the first file and the length of the combination of the other 3 files are different, then some more work is required.