[Shell command] Join corresponding lines with paste

Created on November 30, 2026

Use paste to combine lines at the same position in multiple files. Run these commands to create two sample files.

printf 'alice\nbob\n' > names.txt
printf '24\n31\n' > ages.txt

The following command uses a comma to separate the values.

paste -d ',' names.txt ages.txt
alice,24
bob,31

Without -d, paste uses tabs. It pairs lines by position, so the order of the two input files matters.

Reference

Shell command paste