Chinaunix
标题:
bash下怎么横着合并文件?
[打印本页]
作者:
万里北国
时间:
2006-10-27 16:08
标题:
bash下怎么横着合并文件?
file1内容:
abc
def
ghi
file2内容:
123
456
789
怎么合并成一个file3:
abc123
def456
ghi789
作者:
寂寞烈火
时间:
2006-10-27 16:13
paste filea fileb -d ""
复制代码
作者:
letwave
时间:
2006-10-27 22:23
法王,为什么运行结果说:
paste: -d : No such file or directory
作者:
qqq112233g
时间:
2006-10-27 22:27
sed 'R2' 1|sed 'N;s/\n//'
作者:
qqq112233g
时间:
2006-10-27 22:29
1为file1,2为file2
作者:
寂寞烈火
时间:
2006-10-27 23:25
原帖由
letwave
于 2006-10-27 22:23 发表
法王,为什么运行结果说:
paste: -d : No such file or directory
去看一下paste的manpage,看-d是咋说的
作者:
awk就是awp加ak
时间:
2006-10-28 14:45
join -j1 <(nl -w6 file1) <(nl -w6 file2) |sed 's,[^ ]* ,,' > file3
作者:
letwave
时间:
2006-10-30 16:35
标题:
回复 6楼 寂寞烈火 的帖子
查了一下:用法如下:
文件FILE1:
ddd
xxx
ccc
FILE2:
111
222
333
要使用 paste -d:
paste -d "?" FILE1 FILE2
新生成的文件为:
ddd?111
xxx?222
ccc?333
法王,好像还是不能把之间的空格取消呢,可以把“”里面换成任何字符,但始终都会有东西啊。
作者:
vantien
时间:
2006-10-30 17:13
就是用 -d "" 呀, 你的不能跑吗?
[tmp]$ cat test1
ddd
xxx
ccc
[tmp]$ cat test2
111
222
333
[tmp]$ paste -d "" test1 test2
ddd111
xxx222
ccc333
[tmp]$
作者:
letwave
时间:
2006-10-30 17:15
标题:
回复 9楼 vantien 的帖子
奇怪,我的不能跑,不过我用这个搞定了:
paste -d '\' file1 file2
我的默认的""会提示说我没有给分割符。
作者:
weidi
时间:
2006-10-31 13:59
file1的内容
a1 bb1 cc1 dd1
a2 bb2 cc2 dd2
a3 bb3 cc3 dd3
a4 bb4 cc4 dd4
file2的内容
bb3 tt1
bb2 tt4
bb1 tt3
bb4 tt2
如何得到file3
a1 bb1 cc1 dd1 tt3
a2 bb2 cc2 dd2 tt4
a3 bb3 cc3 dd3 tt1
a4 bb4 cc4 dd4 tt2
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2