GNU paste combines corresponding lines from text files: first with first, second with second, and so on. It does not look up a hostname, account number or other key before pairing values. That makes it convenient for aligned columns, but dangerous when two independently collected reports have different row orders.
Use it when the positional relationship is already established. If records must be matched by an identifier, choose a key-aware merge instead of assuming that a neat-looking two-column result is correct.
Try a disposable two-column example
The following Bash example creates only temporary sample files. It prints a combined result to the terminal without overwriting either input. Run the block in one shell so its workspace variable remains available:
work=$(mktemp -d) || exit 1
printf 'app-a\napp-b\n' > "$work/names.txt"
printf 'ready\npaused\n' > "$work/states.txt"
paste -- "$work/names.txt" "$work/states.txt"
The output contains app-a paired with ready and app-b paired with paused. By default, a tab separates the columns. The spaces displayed by a terminal depend on tab stops; they are not evidence that paste inserted a fixed number of spaces.
The sample files are deliberately simple: one plain-text value per line, no embedded tabs or multiline fields. Real exports may need a parser that understands their format. Keep original reports untouched while checking whether these assumptions hold.
See what happens when one input ends early
Continue in the same shell. Add a third state without adding a third name:
printf 'waiting\n' >> "$work/states.txt"
paste -d '|' -- "$work/names.txt" "$work/states.txt"
The expected lines are app-a|ready, app-b|paused and |waiting. The missing name becomes an empty field. The extra row is not rejected simply because the other file has reached its end.
This is why successful execution is not proof of a valid reconciliation. Investigate empty fields and establish whether every row has its intended partner. Equal row counts are also insufficient: two files can have the same length and still be ordered differently.
Understand delimiters and serial mode
The delimiter option takes a list of delimiter characters, not a multi-character field separator. When there are several boundaries on a row, paste cycles through those characters. For example:
paste -d ',;' -- "$work/names.txt" "$work/states.txt" "$work/names.txt"
paste -s -d ',' -- "$work/names.txt"
The first command uses a comma at the first boundary and a semicolon at the second. Its first line is app-a,ready;app-a. The second command switches to serial mode and joins the lines within the names file, producing app-a,app-b.
A comma delimiter does not make paste a CSV serializer. It does not add the quoting needed when a value itself contains a comma, quote or newline. Use an actual CSV library for structured records that require escaping rather than attempting to repair the output by visual inspection.
Avoid false matches in operational reports
Imagine two host reports collected minutes apart. One lists hostnames alphabetically; the other lists checks in completion order. Pasting them together can attach a healthy result to the wrong machine without producing an error. Preserve identifiers in both reports and verify the mapping before combining data.
Sorting both files independently is not a general fix. Sorting a standalone value column can destroy its relationship with the record that produced it. If sorting is necessary, retain complete records and apply an appropriate common key. The related guide to GNU version sorting for numbered filenames explains one ordering choice, but natural name order still does not establish record identity.
Review checklist and short FAQ
- Confirm that each line is one intended record and that row correspondence is known.
- Check missing rows, empty values and inconsistent collection times.
- Keep identifiers attached to their values throughout any sorting.
- Review terminal output before saving a derived report to a new path.
- Delete only the disposable sample workspace when finished; no production rollback is needed for the read-only inspection commands.
Does paste require sorted inputs? No. It uses their existing line order. Sorting is not required, and unsynchronised sorting can create incorrect pairs.
Does an empty field mean the source contained a blank value? Not necessarily. An exhausted input can produce an empty field too, so check the original files.
Source: the GNU Coreutils manual source, section paste invocation, describing corresponding lines, delimiter cycling and serial mode.
This tutorial is for educational purposes. Test carefully before using any steps in production. The site owner is not responsible for misuse, damage, data loss or production issues.



