The `paste` utility merges corresponding or subsequent lines of files.
Questions tagged [paste]
134 questions
45
votes
10 answers
Text processing - join every two lines with commas
I have more than 1000 lines in a file. The file starts as follows (line numbers added):
Station Name
Station Code
A N DEV NAGAR
ACND
ABHAIPUR
AHA
ABOHAR
ABS
ABU ROAD
ABR
I need to convert this to a file, with comma separated entries by joining…
mtk
- 26,802
- 35
- 91
- 130
16
votes
6 answers
A better paste command
I have the following two files ( I padded the lines with dots so every line in a file is the same width and made file1 all caps to make it more clear).
contents of file1:
ETIAM......
SED........
MAECENAS...
DONEC......
SUSPENDISSE
contents of…
Tulains Córdova
- 2,926
- 4
- 18
- 26
15
votes
6 answers
Combining large amount of files
I have ±10,000 files (res.1 - res.10000) all consisting of one column, and an equal number of rows.
What I want is, in essence, simple; merge all files column-wise in a new file final.res. I have tried using:
paste res.*
However (although this seems…
mats
- 249
- 4
- 9
13
votes
2 answers
paste files without delimiter
How do I join two files vertically without any separator? I tried to use paste -d"" a b, but this just gives me a.
Sample file:
000 0 0 0
0001000200030004
10 20 30 40
2000 4000
.123
12.1
1234234534564567
Tomas Greif
- 349
- 1
- 4
- 12
12
votes
3 answers
paste command: setting (multiple) delimiters
In Linux, I have the following problem with paste from (GNU coreutils) 8.13:
Trying to set another delimiter than the default (TAB) results in either just printing the first character of the defined delimiter or perfectly ignoring it.
Question: How…
erch
- 4,890
- 17
- 49
- 81
11
votes
2 answers
How to copy text from command line to clipboard without using the mouse?
I'm trying to figure out a way to copy the current text in a command line to the clipboard WITHOUT touching the mouse. In other words, I need to select the text with the keyboard only.
I found a half-way solution that may lead to the full…
Sancho Pancho
- 123
- 1
- 6
11
votes
4 answers
How to interleave the lines of two or more files?
I have tried to get the 2 files output in a single file. I have tried below command:
cat file1 file2
but here file2 data is appending to file1.
What I need is file1 1st line followed by file2 first line, and file1 second line followed by file2…
user73553
- 355
- 3
- 6
9
votes
1 answer
How to merge two files in corresponding row?
Now,I have two files:
aaaa.txt:
a=0;
b=1;
c=2;
bbbb.txt:
d=3
e=4
f=5
I want to merge aaaa.txt and bbbb.txt to cccc.txt.
cccc.txt as follow:
a=0;d=3
b=1;e=4
c=2;f=5
So, what can I do for this?
binghenzq
- 581
- 2
- 7
- 13
9
votes
7 answers
How can I apply `cut` to several files and then `paste` the results?
I often do operations like
paste <(cut -d, -f1 file1.csv) <(cut -d, -f1 file2.csv)
which is very tedious with more than a few files.
Can I automate this process, e.g. with globbing? I can save the cut results with
typeset -A cut_results
for f in…
shadowtalker
- 1,198
- 2
- 11
- 23
9
votes
5 answers
Merge alternate lines from two files
File1:
.tid.setnr := 1123
.tid.setnr := 3345
.tid.setnr := 5431
.tid.setnr := 89323
File2:
.tid.info := 12
.tid.info := 3
.tid.info := 44
.tid.info := 60
Output file:
.tid.info := 12
.tid.setnr := 1123
.tid.info := 3
.tid.setnr := 3345
.tid.info…
Nainita
- 2,712
- 12
- 33
- 50
8
votes
1 answer
How to merge text file vertically?
Let's assume that I've got two text file a, b.
$cat a
a a
a a
a a
$cat b
b b
b b
b b
Then, I want to merge these two file vertically by using paste. The merged file is shown bellow
a a
a a
a a
b b
b b
b b
NOT
$paste a b > AB
$cat AB
a a b b
a a b…
comphys
- 319
- 1
- 3
- 7
8
votes
4 answers
Is there a command can do the reverse of what the paste command does?
The paste command can merge multiple lines into one. For example, if I have a file test.txt and it contains:
original text
a
aa
aaa
b
bb
bbb
c
cc
ccc
I can use the command paste -s -d '\t\t\n' test.txt to get:
processed result
a aa aaa
b bb …
Just a learner
- 1,766
- 4
- 22
- 32
8
votes
2 answers
How to paste output of multiple commands
I want to merge two unzipped files f1 and f2 in one command, like
paste (zcat f1.gz) (zcat f2.gz).
What is the right syntax?
user196711
- 181
- 1
- 2
8
votes
2 answers
Select certain column of each file, paste to a new file
I have 20 tab delimited files with the same number of rows. I want to select every 4th column of each file, pasted together to a new file. In the end, the new file will have 20 columns with each column come from 20 different files.
How can I do this…
Jun Cheng
- 105
- 1
- 1
- 5
7
votes
1 answer
What is the correct way to merge two ASCII art files side by side while preserving alignment?
art_file (cat -A output):
.::""-, .::""-.$
/:: \ /:: \$
|:: | _..--""""--.._ |:: |$
'\:.__ / .' '. \:.__ /$
||____|.' _..---"````'---. '.||____|$
||:. |_.' …
puwlah
- 519
- 4
- 10