When to use paste
Use paste to join corresponding text lines side by side or collapse lines into one record. Check that the input files have compatible ordering; this tool matches by line position, not by a key.
Syntax
paste [OPTIONS] [FILE...]Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Merge Columns
paste ./names.txt ./values.txtEach pair of lines is joined with a tab separator.
Join separated by commas
paste -d, ./names.txt ./values.txtA comma replaces the default tab, but output is not automatically escaped as CSV.
Collect lines into one
paste -sd, ./names.txtAll input lines are combined into a single comma-separated line.
Notes and limitations
- By default, lines are concatenated by tabs; The number of lines in the files may vary.
- The utility does not escape special characters CSV.
Common questions and troubleshooting
Can paste join records by an ID column?
No. It combines line positions. Use join on appropriately prepared inputs or a structured data tool for key-based matching.
Why is the resulting comma-separated file invalid?
Embedded commas, quotes or newlines are not CSV-escaped automatically. Use a CSV writer when those characters are possible.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man paste.