Questions tagged [paste]
The `paste` utility merges corresponding or subsequent lines of files.
124
questions
2
votes
1
answer
62
views
Why does paste command truncate one of the input files?
I have two files which contain only one column of numeric data each, and the same number of rows. When using paste, it does combine the rows from the two files into one row, but the text of the first ...
0
votes
1
answer
95
views
Merge all csv files in directory column wise
Say the directory contained 3 csv files:
The first csv:
Name, John
Age, 18
The second csv:
Name, Jim
Age, 21
The third csv:
Name, Amy
Age, 22
I would want the result to be:
Name, John, Jim, Amy
Age,...
0
votes
1
answer
38
views
Understanding the unix Paste command with input redirection
I am trying to understand the implementation of the paste command in unix when there is a file from input redirection.
Assuming the following files:
A.txt:
A
B
C
D
B.txt:
1
2
3
4
The unix command:
...
4
votes
3
answers
280
views
Merging files based on potentially incomplete keys
I want to merge two files like How to merge two files based on the matching of two columns? but one file may not have all results. So for example
file1
1 dog
2 cat
3 fox
4 cow
file2
1 woof
2 meow
4 ...
0
votes
1
answer
23
views
Incorrect overlapping of lines with Unix paste
I have one file called file1, which contains the following lines
you are searching for a four .
you are searching for a six .
you are searching for a three .
you are searching for an ace .
you are ...
1
vote
0
answers
43
views
paste command with Variables instead of files
I have 3 variables , TITLES , SIZE and NUMBER.
I want to concat them like so
"NUMBER TITLE SIZE"
This variables are multi line strings.
eg:
echo $NUMBER
1
2
3
...
I know that for files ...
0
votes
0
answers
91
views
Combine .gz file with .tsv file (columns) using command line
I have two files.
.gz file with with dimensions 12m x 5 columns
.tsv file (no compression) with the same 12m rows and 9 more columns
I normally would do this in R where I would read in both objects, ...
7
votes
1
answer
253
views
What is the correct way to merge two ASCII art files side by side while preserving alignment?
art_file (cat -A output):
.::""-, .::""-.$
/:: \ /:: \$
|:: | _..--""""--.._ |:: |$
'\:.__ / .' ...
0
votes
0
answers
49
views
middle mouse paste with ctrl only
While editing with vi, I often paste something in the middle of my document without noticing, especially when scrolling. I would like to disable middle mouse pasting, except when the control button is ...
0
votes
1
answer
85
views
create two new lines using paste command in bash
I'd like to paste three files into a single file with two spaces between each file using the paste command in linux bash:
paste -d '\n\n' file1.txt file2.txt file3.txt > output.txt
However, there ...
0
votes
2
answers
53
views
How to merge two files of different number of lines using blank line condition?
I have two files, one have diffrent section separted by blank line as follows
a11 a12 a13
b11 b12 b13
c11 c12 c13
a21 a22 a23
b21 b22 b23
c21 c22 c23
d21 d22 d23
a31 a32 a33
b31 b32 b33
the second ...
5
votes
4
answers
399
views
How to print multi-line variables in side-by-side columns in sh?
This question is based on a similar question on Ask Ubuntu,
but instead of bash, I would like to have similar output in sh.
No issue in bash; it works as expected.
wolf@linux:~$ echo $SHELL
/usr/bin/...
1
vote
1
answer
33
views
merge x and x + n lines
I am writing a script which returns 15 lines of titles and 15 lines of URLs.
title 1
title 2
title 3
*snip*
title 14
title 15
http://example.com/query?1
http://example.com/query?2
http://example.com/...
0
votes
1
answer
175
views
How to to create a new file with specific columns from files in multiple folders in linux?
I have .tsv files in more than 100 directories. I want make a single file with all the information needed from all those tsv files in the 100 directories.
For example:
Data
|___ SOB33D
|___ ...
4
votes
3
answers
393
views
Fast version of paste
paste is a brilliant tool, but it is dead slow: I get around 50 MB/s on my server when running:
paste -d, file1 file2 ... file10000 | pv >/dev/null
paste is using 100% CPU according to top, so it ...
0
votes
3
answers
61
views
Linux one row from first file combine into multiple rows in second file, transpose denormalize
File_1
Group Country Lang
IT USA ENG
File_2
EMPID STOREID
1001 1400
1002 1401
1003 1401
If I use
paste -d'\t' File_1 File_2
I get
Group^ICountry^ILang^IEMPID^ISTOREID$
IT^IUSA^...
2
votes
3
answers
276
views
Paste all files in directory column-wise by last modification order
I am looking to combine all files in a directory (each having one column) into a single file with multiple columns. However, I need the files to be pasted by last modification time order, i.e. in the ...
1
vote
0
answers
169
views
can't copy screenshot in KDE/Debian 10
I have Debian 10 with KDE. Everything was working fine and suddenly today when I tried to copy a screenshot it didn't work. When I press the printscreen key, I get the popup showing the screenshot ...
0
votes
1
answer
1k
views
select rows based on specific column values [duplicate]
How can I select all rows in a text file based on different values of a particular column? The desired values are not in a specific interval.
A short example of what I expect is given below.
My data ...
0
votes
5
answers
153
views
How to "paste" two files without writing to a new file? [closed]
I am doing this
for pathname in /user/home/file_*; do
cat "$pathname" | sed -n '3p'; printf"\n";
done> user/home/foo;
for pathname in /user/home/file_*; do
cat "$...
1
vote
1
answer
1k
views
sort multiple files and merge
I want to sort several text files in reverse order and then merge/cat to one single text file.
a.txt
0 33.1
2 33.0
10 21.1
20 21.8
b.txt
0 30.1
2 33.0
10 28.1
20 27.8
and so on *.txt ...
2
votes
1
answer
108
views
Using tee and paste results in a deadlock
I am trying to redirect stdout of a command into two "branches" using tee for separate processing. Finally I need to merge results of both "branches" using paste. I came up with the following code for ...
1
vote
1
answer
58
views
How do I cut text from one file and replace it with text in another file?
I have a text file, mac.txt, with one line that looks like this:
4a:38:61:e1:71:7c
... and I have a bash script, mask.sh, that simply changes my MAC address:
#!/bin/bash
sudo ifconfig wlan0 down
...
2
votes
2
answers
112
views
Append a column to a file based on line number
I have a list of numbers which i would like to add to the end of another file as the final column:
1:.196
5:.964
6:.172
The numbers in front (1,5 and 6) indicate at which line the numbers have to be ...
3
votes
2
answers
1k
views
how can I slow down pasting text into a serial terminal?
I'm working on a raspberry pi, and trying to paste some text files into a command-line text editor nano... but the text ends up corrupted on the remote end (partial/incomplete text).
I can only guess ...
0
votes
1
answer
63
views
Paste: combine rows for each row, up to only the number of rows in the smallest row-ct file
Suppose I have two files,
// foo
a
b
c
d
// bar
x,y,z
p,d,q
The problem is:
paste -d ',' foo bar
...
a,x,y,z
b,p,d,q
c
d
Instead, I would like to (somehow) produce the following:
a,x,y,z
b,...
2
votes
2
answers
2k
views
How to merge text files - Bash script
I want to write a script that takes text files as arguments and merge them.
All the files consist of grouped lines divided by empty lines.
The script can take more than 2 arguments
The files can ...
1
vote
4
answers
509
views
how to divide each one element from a column to each element of other column?
I have two column in one file :
1 2
3 5
4 8
9 18
3 5
4 19
I want to divide each element of first column to each element of second column and want to print that number too.
for example:
...
2
votes
3
answers
159
views
How do I add numbers from two txt files and write it to the same file?
I want to add numbers from two txt files. The number will change in file1, and file2 should update itself like this file2 = file1 + file2. Decimals not needed.
Example:
file1
3
file2
7
Output:
...
0
votes
2
answers
37
views
Append file with two extra colums to a large table?
I need to paste two columns (in a file) to a very big file with an identical number of columns (length 48554). I have tried this
I have two files with columns separated by tabs. File 1 looks like this:...
0
votes
1
answer
121
views
If I save file to my hdd (not ssd), move 2 trash, then cut /paste from trash to usb, will this hold up to forensic analysis designed to recover files?
If I save a file (.odt,.txt, jpeg, etc) to my hdd (not ssd), move to trash, then cut /paste the files in the trash to a usb, would this hold up to the best forensic equipment trying to recover the ...
3
votes
3
answers
71
views
regex from two files
I have two files that built of blocks of 4 lines, starting with a @. They are matching and in order. The files are too big (>10 GB) so I am putting here the first 3 blocks of each (12 lines).
1st: ...
1
vote
2
answers
71
views
How to make paste -d second file print down while looping?
I would like to make the second file label 'b' print down the first file label 'a', like shifting down the file creating new lines I want it to print all the way down until the first line of the ...
2
votes
1
answer
223
views
Paste & Brace Expansion vs Wildcard
Why does a brace expansion behave differently than wildcard in combination with paste?
Example:
Assume we have multiple folders, each containing the same-structured tsv and want to create a 'all.tsv' ...
0
votes
1
answer
132
views
vim pastes onto completely wrong location
This has not just once, but happened many times. I'm not sure what I'm doing wrong.. it tends to occur more frequently during remote control. I would set the mouse cursor at a certain position where I ...
0
votes
2
answers
56
views
Joining a standard output and susbtitution thereof into table
Say I have:
$ cat tmp1.txt
a
b
c
Then
$ paste tmp1.txt <(tr '[:lower:]' '[:upper:]'<tmp1.txt)
a A
b B
c C
How would I modify the above to
1/ invoke tmp1.txt only once? (I suspect tee)...
2
votes
3
answers
656
views
Format output file from paste command
I have two or more files
FileA
A: 18.49 RPKM
C: 14.49 RPKM
B: 18.89 RPKM
FileB
A: 21.29 RPKM
C: 38.71 RPKM
B: 36.13 RPKM
I want to paste these two files and print first-column ...
0
votes
3
answers
64
views
Combining multiple columns and insert information in middle
I have to 3 files with all containing columns of information
id.file
1
2
3
name.file
Josh
Kate
Chris
lastname.file
Smith
Jones
Black
And I would like to combine them in a way, so I can get ...
0
votes
0
answers
26
views
Merging two columns causes them to skip lines
I am trying to combine two text files each containing one column of numbers, I am using paste method to achieve this, but when I run my script it doesn't put them together correctly rather it skips a ...
1
vote
1
answer
307
views
Calculate difference in negative floating numbers with bc
I want to calculate the difference between two negative floating numbers and subsequently check if the result is below a certain threshold. The numbers are stored in the file.dat, since this ...
0
votes
1
answer
63
views
how can I pass over a string on several txt files
I have a data like this but much bigger. So I have a df1.txt as follow
sp|O15304|SIVA_HUMAN ...
1
vote
2
answers
86
views
How do I align columns at common elements but give differing elements their own rows?
I am using paste to merge three text files (which do not require sorting) into a single document with three columns.
paste a.txt b.txt c.txt
I'd like elements that the columns have in common to ...
3
votes
3
answers
973
views
Why can't `paste` print stdin next to stderr?
Usually paste prints two named (or equivalent) files in adjacent columns like this:
paste <(printf '%s\n' a b) <(seq 2)
Output:
a 1
b 2
But when the two files are /dev/stdin and /dev/...
0
votes
1
answer
142
views
one-liner to delete a part of a column with matching pattern (sed/awk etc)
A very generic question but I am looking for the simplest way solve this very quickly and efficiently
I have a file with a very large number of lines which looks like this
451267 sample1.txt
...
0
votes
2
answers
972
views
Copy line in text file and add modified line to the end of line in same file
I would like to copy line in text file edit it on the fly to replace all / to | and paste in on the same line in the same line.
I have the first line in the text file:
http://webpage.com/(name-never-...
5
votes
3
answers
1k
views
How to merge the different lines of files?
What is the fastest command line way to merge the different lines of files? For example, I have two files:
a.txt:
foo
bar
foobar
b.txt
foo
foobar
line
by
bar
And I would like to get the ...
1
vote
2
answers
764
views
How to transpose x and y axis of table, using cut & paste shell commands
I need to transpose x and y axis, of a file of 450.000 × 15.000 tab separated fields, so I tried first with a small 5 × 4 test file named A.txt:
x column1 column2 column3
row1 0 1 2
row2 ...
2
votes
3
answers
185
views
Giving a common path for a group of files into a bash script
The purpose of following script is to merge several tables and put them in an specific directory by using paste command.
for i in {1..30}
do
paste ./directory"$i"/table1.txt table2.txt ... table20....
0
votes
2
answers
1k
views
Git-bash UNIX: Switch columns/fields using cut?
So I have a file with 2 columns as follows:
10 1
11 2
12 3
13 4
14 5
I would like to switch the columns using the cut command. I've used
paste <(cut -f2 file.dat) <(cut -f1 ...
1
vote
0
answers
254
views
Paste contents of many files together within a vi bash script [duplicate]
I cannot seem to get a paste command to work in a bash script. The command pastes the contents of a range of files together and outputs a new combined file. This is what works outside the script if I ...