pastex
Merge lines of files.
Mirrors GNU paste. Run it as pastex, or as gnux pastex.
Synopsis
pastex [OPTION]... [FILE]...GNU reference
Description
pastex writes lines made of the corresponding lines of each FILE, separated by TABs, to standard output. With no FILE, or when FILE is -, it reads standard input; every - reads the same standard input, so 'pastex - -' joins pairs of lines. A file that runs out of lines contributes empty fields while the others continue. -s pastes one file at a time instead, turning each file into a single line. -d LIST uses the characters of LIST as delimiters instead of TAB, cycling through them and starting again from the first on every output line (and, with -s, for every file). LIST understands the escapes \n, \t, \, \b, \f, \r, \v and \0, the empty delimiter. -z makes NUL the line delimiter. Delimiters are single bytes: a multibyte character in LIST is used one byte at a time.
Permissions
Needs read permission on each FILE and search permission on the directories leading to it. Nothing is ever modified.
Use cases
- Putting two lists side by side, one column each.
- Joining every two or three lines of a file into one with '
pastex- - < file'. - Turning a list of lines into one comma-separated line with
-s -d','. - Building a CSV from columns kept in separate files.
- Summing a column of numbers by joining it with '+' for another tool.
- Merging a file of keys and a file of values line by line.
Flags
-d, --delimiters LIST reuse characters from LIST instead of TABs
--help display this help and exit
-s, --serial paste one file at a time instead of in parallel
--version output version information and exit
-z, --zero-terminated line delimiter is NUL, not newlineExamples
Put two files side by side, separated by a TAB
pastex names.txt ages.txtUse a comma instead of a TAB
pastex -d , names.txt ages.txtJoin all the lines of a file into one comma-separated line
pastex -s -d , hosts.txtJoin every two lines of standard input
printf 'a\nb\nc\nd\n' | pastex - -Lay a list out in three columns
seqx 9 | pastex - - -Cycle through several delimiters
pastex -d ',;' a.txt b.txt c.txtJoin columns with no delimiter at all
pastex -d '\0' first.txt last.txtShow each file as one TAB-separated line
pastex -s a.txt b.txtPaste NUL-terminated records
pastex -z keys.bin values.binTurn a column of numbers into one sum expression (1+2+3+4+5)
seqx 5 | pastex -s -d +Paste in the portable gnux shell
gnux shell -c 'seqx 6 | pastex - - | sortx -rn'Options
Each option has a page of its own, with its usage and examples.
- -d, --delimiters: Reuse characters from LIST instead of TABs.
- -s, --serial: Paste one file at a time instead of in parallel.
- -z, --zero-terminated: Line delimiter is NUL, not newline.
Exit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
pastex --help # options, first examples, exit status
gnux help pastex # this page: the full manual
gnux help pastex --OPTION # one option in depth, with its examples