[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature request for coreutil paste
From: |
Bruno Haible |
Subject: |
Re: feature request for coreutil paste |
Date: |
Fri, 17 Oct 2008 03:23:44 +0200 |
User-agent: |
KMail/1.5.4 |
Robert C. Kahlert wrote:
> File #1:
> abc
> def
> ghi
> jkl
> mno
>
>
> File #2:
> 1
> 2
>
> Output of paste file1 file2
> abc 1
> def 2
> ghi 1
> jkl 2
> mno 1
It can already be done with a combination of 'paste', 'cat', 'head', 'wc':
$ while :; do cat file2 || exit; done | head -n `wc -l < file1` | paste file1 -
abc 1
def 2
ghi 1
jkl 2
mno 1
If some new options were to be introduced for this use-case, it would be
preferrable to introduce two new, more widely applicable options:
1) An option "paste --shortest" that causes 'paste' to terminate when one
of the input files has reached its end,
2) An option "yes -f FILE" or "cat --repeat FILE" that has the same effect as
(while :; do cat file2 || exit; done)
The solution could then be written as
$ yes -f file2 | paste --shortest file1 -
Bruno