If you have a tool only working on files as input (e. g. diff
or paste
), you can use the <(…)
notation to create a fake file whose contents is created by a shell command:
cat <(echo "hello world")
This will print hello world
. The fake file lacks some of the abilities of on-disk files; it cannot be seek
ed for instance. So programs which want to seek
a specific position in the file, for instance to read the file twice, will fail on this. But for your case, it should suffice and you can use stuff like this:
paste <(echo "$a") <(echo "$b")
For your case more concrete:
cat input.txt | {
x=''
y=''
while read a
do
read b
x=$(echo "$x"; echo "$a")
y=$(echo "$y"; echo "$b")
done
paste <(echo "$x") <(echo "$y")
}
(I'm assuming the input to be this here:)
00001
Tacos
00023
pizza
00076
burger
00103
chopsuey
00167
burrito
01034
Tamales