linux按列拼接文件

需求是快速生成如下的网址列表

分解需求:
第一部分 https://hqidi.com/ 是完全一样的,先生成这一部分:

for i in {1..78};do echo "https://hqidi.com/" >>/tmp/urls.txt ;done

[root@dish tmp]# cat urls.txt 
https://hqidi.com/
https://hqidi.com/
https://hqidi.com/
https://hqidi.com/
https://hqidi.com/
https://hqidi.com/
https://hqidi.com/
https://hqidi.com/
https://hqidi.com/
https://hqidi.com/
https://hqidi.com/

第二部分是个数字序列:

for i in {1..78};do echo $i >>/tmp/sz.txt ;done

[root@dish tmp]# cat sz.txt 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

第三部分也是完全一样的:

for i in {1..78};do echo ".html" >>/tmp/nf.txt ;done

最后把这三个文件用paste拼起来
paste urls.txt sz.txt nf.txt
因为paste默认的界定符是制表符,所以拼接效果如下

https://hqidi.com/	1	.html
https://hqidi.com/	2	.html
https://hqidi.com/	3	.html
https://hqidi.com/	4	.html
https://hqidi.com/	5	.html
https://hqidi.com/	6	.html
https://hqidi.com/	7	.html
https://hqidi.com/	8	.html
https://hqidi.com/	9	.html
https://hqidi.com/	10	.html
https://hqidi.com/	11	.html
https://hqidi.com/	12	.html
https://hqidi.com/	13	.html
https://hqidi.com/	14	.html
https://hqidi.com/	15	.html
https://hqidi.com/	16	.html
https://hqidi.com/	17	.html
https://hqidi.com/	18	.html

我们指定一下界定符:

paste urls.txt sz.txt nf.txt -d ""

目标达成。

原创文章,转载请注明: 转载自笛声

本文链接地址: linux按列拼接文件

暂无评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Copyright © 2015-2024 笛声博客 All Rights Reserved     浙ICP备15036123号-1