One way with join
:
echo | join input - -a 1 -o "1.1 1.2 1.3 2.1" -e x
Though just doing a sed
replace should be much better.
سؤال
How to produce the same string for x number of lines and then use paste to combine the files: I have a file as such with unknown number of lines, e.g.:
$ echo -e "a\tb\tc\nd\te\tf" > in.txt
$ cat in.txt
a b c
d e f
I want to concat the files with a new column that has the same string for every row. I have tried using echo to create a file and then using paste to concat the columns but i have to know the number of rows in in.txt
first and then create a in2.txt
using echo.
$ echo -e "a\tb\tc\nd\te\tf" > in.txt
$ cat in.txt
a b c
d e f
$ echo -e "x\nx\n" > in2.txt
$ paste in.txt in2.txt
a b c x
d e f x
How else can I achieve the same output for an unknown number of lines in in.txt
?, e.g.
[in:]
a b c
d e f
[out:]
a b c x
d e f x
My data consist of a million lines with 3 columns in in.txt
of 50-200 chars for each line, so solution needs to keep the "big" data size in mind.
المحلول
One way with join
:
echo | join input - -a 1 -o "1.1 1.2 1.3 2.1" -e x
Though just doing a sed
replace should be much better.