Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [paste]

The `paste` utility merges corresponding or subsequent lines of files.

1
vote
2answers
54 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 ...
0
votes
0answers
21 views

How to paste a timestamp (YYYYMMDDHHMMSS) immediately anywhere using hotkey, without reserving the clipboard?

I would like to paste an YYYYMMDDHHMMSS timestamp everywhere with a specified keyboard key or combination. Here is a way to do so: http://www.arcadien.net/node/48 But this reserves the clipboard, ...
3
votes
3answers
127 views

How to `paste` 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
1answer
27 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
2answers
46 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-...
4
votes
3answers
380 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
2answers
60 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
3answers
25 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
2answers
92 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
0answers
41 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 ...
0
votes
2answers
38 views

Formatting columns of an output text [duplicate]

I have 3 files file1: compute-0-44 compute-0-2 compute-0-7 compute-0-8 file2: 0 11/29/2017 | 02:01:34 0 05/16/2018 | 08:47:56 file3: 0 963 0 459 When I do paste file1 file2 file 3, I get : ...
1
vote
1answer
54 views

how to copy and paste only a specific column in each file?

I have nearly 400 files, each looks like this: head HI.1.Q091_13R_all_PA_code Ha8_00040788 C Ha4_00024045 C Ha4_00025366 C Ha16_00022130 C Ha16_00023451 C Ha8_00040789 C Ha4_00025367 C Ha4_00024046 A ...
1
vote
0answers
34 views

Removing ^M from shell script and realigning columns

I have a shell script that I am asking to print the columns I pasted together. Then I'm asking it to realign the columns after its pasted and then take out the ^M character . My code is paste ...
0
votes
1answer
77 views

Create header to table from the output of the command “paste”

I have folder (data) contain large number of text files. Each text file contain one column of numbers, the column contain 30 numbers. I want to create table that combine the columns in these text ...
0
votes
1answer
43 views

pasting files in unix

I have a folder with multiple files: W1747_RH_sig_window_outliers_g_chrom W1747_RH_sig_window_outliers_g_pos W1747_RH_sig_window_snps_g_chrom W1747_RH_sig_window_snps_g_pos ...
3
votes
3answers
467 views

How to parse input file once and send to two separate streams and display side-by-side?

I've got the following script: #!/usr/bin/env bash # Script to generate MD5 hash for each line. [ $# -eq 0 ] && { echo "Usage: $0 file"; exit 1; } file=$1 shopt -s expand_aliases alias ...
0
votes
0answers
33 views

Inconsistent “paste” executable behavior

To start, apologies if this is addressed somewhere already. Because of the name of the executable, my search results weren't relevant. Anywho, I'm using "paste" on Ubuntu to seam several text files ...
1
vote
2answers
59 views

How to combine alternate lines in a file?

I have a 4 line input file and i need to modify the file to combine alternate lines. I want to perform the operation in place. INPUT: Tom Nathan Jack Polo Desired Output: Tom Jack Nathan Polo ...
3
votes
4answers
116 views

How to make `paste` command stop on shortest file

I have two files: a.txt 1 2 3 b.txt foo bar baz qux Running paste a.txt b.txt gives 1 foo 2 bar 3 baz qux However I want to stop when the shortest file ends (that is, I want to print only ...
2
votes
3answers
287 views

How to print the second column of many files?

I have more than 10 files, the 1st column is the same in all files, I need to collect all the columns 2 in all files against the 1st column in one file. I tried with paste then awk but this print only ...
3
votes
4answers
471 views

Combine list of words into one line, then add characters

I want to take a file that has a list of words on each line of its own eg. act bat cat dog eel and put them into one line with comma separated and quoting them. So that it turns out like: 'act', '...
2
votes
2answers
4k views

How to join files with required columns in linux?

I have many files like following in a directory "results" 58052 results/TB1.genes.results 198003 results/TB1.isoforms.results 58052 results/TB2.genes.results 198003 results/TB2.isoforms.results 58052 ...
4
votes
4answers
1k views

Print two files in two columns

I want to print two files in two columns -- first file on the left side and second on the right side. paste doesn't do the job, since it can only insert a character as delimiter. If first file has ...
0
votes
2answers
109 views

how to paste several file together using a single space as a delimiter [duplicate]

These are 3 files: file1 file2 file3 1 2 3 1 1 1 3 3 3 2 1 3 1 1 1 3 3 3 0 0 0 1 1 1 3 3 3 I want to join them together and have a final file like: 1 2 3 1 1 1 3 3 3 2 1 3 1 1 1 3 3 ...
0
votes
2answers
486 views

Append first column to file

I have a file that looks like this: Heading1,Heading2 value1,value2 And another one that looks like this: Row1 Row2 How can I combine the two to become: Row1,Heading1,Heading2 Row2,value1,value2 ...
1
vote
1answer
39 views

Horizontally concatenating periodically

I have 2 files namely f1 and f2. File f1 keeps getting new output periodically in the form $cat f1 a b c After "x" seconds $cat f1 e f g After "2x" seconds $cat f1 h i j and so on. ...
0
votes
1answer
38 views

Strange behavior of paste [closed]

I am experiencing some strange behavior of the paste tool. For some reason it appears to not do it's job on two specific files, but I cannot reproduce that behavior with other files. The first file: ...
1
vote
1answer
534 views

how to add output as a new column with the file names

How can I add output of each file incrementally in one singel output? I want to do this instead of running paste command on all files together. It is because I have 10k files and each file is 100 GB ...
0
votes
1answer
285 views

When do you need “…|while read…”?

I saw a video tutorial for the paste command, in which three files foo,bar,baz were connected horizontally with a "+" sign between. cat foo 51 33 67 cat bar 10 1 13 cat baz 7 100 15 So, he used a ...
1
vote
2answers
61 views

How can I paste files with the same name from different directories?

I have another question. I have three different directories but I have the same files inside, with the same name. For example: Directory1: dir1/file1.txt dir1/file2.txt dir1/file3.txt Directory2: ...
3
votes
1answer
6k views

How to merge text file vertically? [duplicate]

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 ...
9
votes
1answer
3k views

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-...
1
vote
3answers
355 views

Why paste command doesn't work for Concatenating two files column wise when the characters are more than 511?

I am using a paste command to concatenate two .csv files column wise. These both files are huge file and when I run the paste command as below where comma(,) is the delimiter: paste -d',' file1.csv ...
4
votes
2answers
252 views

How do I append text from one line, to the end of another?

The original output file contained this block of text among much more information: Projecting out rotations and translations Force Constants (Second Derivatives of the Energy) in [a.u.] ...
0
votes
1answer
72 views

Paste command is not one to one

I have a file called phone_dir.txt (2 lines for example): ADAMS, Andrew 7583 BARRETT, Bruce 6466 I try to extract the last names and capitalize them, the output required is: Adams Barret I can ...
1
vote
1answer
86 views

Paste text files and add parent directory name as header for each column

In a parent folder I have multiple folders inside it. Within each folder I have text file "text.txt". The text files are similar in all the folders, each text file contain 100 line and one column of ...
3
votes
4answers
1k views

paste and save the result to the 1st argument without using temp files

I would like to use paste to add new column in original file "first.xls". My files: first.xls 1 1 1 second.xls 2 2 2 I'm using: paste -d'\t' first.xls second.xls >> first.xls and I get ...
2
votes
1answer
360 views

Command to “fill down” columns in text file, a la the Excel fill down function

I have a text file with rows, and columns within those rows. I want to, essentially, replicate the Excel "fill down" function. In other words, if there is a blank "cell" on a line, it will look to the ...
6
votes
3answers
2k views

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....
0
votes
1answer
228 views

Join lines from two files

I'm trying to combine two different files, one called itemnum and another called items. itemnum contains: ItemNumber 1201 1221 1320 1340 1410 and items contains: Item Lobby Furniture Ballroom ...
1
vote
1answer
348 views

Paste different csv files

I have a bunch of input csv files (delimited with semi-colon ";" having the following format YEAR;MONTH;DAY;RES1FILE1;RES2FILE1;RES3FILE1 1901;01;01;101;154;169 1901;01;02;146;174;136 The number of ...
0
votes
3answers
53 views

How to simply cut and paste from an editor on a remote machine to a local machine?

My Windows laptop uses a VirtualBoxed Linux machine to connect to a remote machine, both using Ubuntu 14.04 LTS. On the remote machine I look at files using nano or less. How do I copy part or all of ...
0
votes
2answers
353 views

how to paste a file into another file (turn one), but one under the other?

I want to paste one file (with vectos 1xn) in another file? Example: File1 rs01 rs02 rs03 File2 AA BB CC How I can do this? But in my case, I have 55,000 column in File1 and File2, so, ...
1
vote
0answers
28 views

Use a result twice in a pipeline [duplicate]

I have two programs progA and progB ./progA outputs a list like this : a1 a2 a3 a4 and ./progB take the result of progA as an argument and also outputs a list : b1 b2 b3 b4 I can pipe them like ...
0
votes
1answer
91 views

Awk to get same column with maximum filed

I have two files. I have to get matching name from file1, print the entire content of file1, and add a fourth column (exp) in file 1 using a second file with max value file1 name value1 ...
1
vote
1answer
781 views

I need to merge multiple .csv files together side by side with unequal number of rows

I have anywhere from 3-5 .csv files and need to be able to merge them together while keeping everything in its respective columns below is an easy example with files with varying number of rows. file1 ...
1
vote
1answer
405 views

How to copy text of virtual terminal from graphics mode?

Linux have virtual terminals, one can switch between them with chvt 1, chvt 7 commands. Former is in the text mode, later is in the graphics mode. I want to copy all the text from first terminal, ...
3
votes
3answers
474 views

Intersperse lines from two files

I have a data file ($file1) which contains two lines of data per individual. I need to intersperse a third line of data from another data file ($file2). So my input looks like: >cat $file1 bob ...
3
votes
2answers
403 views

Merge and Append columns for more than 2 files

The files are tab separated. I have "N" number of files whose contents are as shown in the screenshot above. I want to merge them and append the 5th column. The first 4 columns are the same. I tried ...
4
votes
1answer
1k views

Loop through files and join horizontally

I am trying to do the following: Loop through a list of files Edit each file and output a "trimmed" file Horizontally join each trimmed file in turn to a pre-made master file I have steps 1 & 2 ...